$ cat /etc/logrotate.d/nginx
/var/log/nginx/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
invoke-rc.d nginx rotate >/dev/null 2>&1
endscript
}
^_^[root@mitesh.com:~]# invoke-rc.d nginx rotate
initctl: invalid command: rotate
Try `initctl --help' for more information.
invoke-rc.d: initscript nginx, action "rotate" failed.
^_^[root@mitesh.com:~]# service nginx rotate
* Re-opening nginx log files nginx
$ ansible ALL -m shell -a "sudo sed -i 's/invoke-rc.d nginx rotate/service nginx rotate/' /etc/logrotate.d/nginx"
$ ansible ALL -m shell -a "sudo service nginx rotate"
NOTE!: If you are not sure what is Ansible then check out some Ansible Tutorials.