nginx logrotate error on cron job

The post rotate action appears to be incorrect

Try

invoke-rc.d nginx reload >/dev/null 2>&1

If you look at the nginx command you will see the actions it will accept. Also the message you got says check initctl --help

xtian@fujiu1404:~/tmp$ initctl help
Job commands:
  start                       Start job.
  stop                        Stop job.
  restart                     Restart job.
  reload                      Send HUP signal to job.
  status                      Query status of job.
  list                        List known jobs.

so reload should work and send HUP signal to nginx to force reopen of logfiles.


As mentioned in another answer, the problem is that invoke-rc.d nginx rotate returns an error stating that the rotate action is not supported. The interesting thing is that service nginx rotate works without issues.

My guess is that the invoke-rc.d wrapper doesn't support all the actions the actual nginx init script supports.

Changing invoke-rc.d nginx rotate to service nginx rotate should solve the issue.


I'm not sure if it because initctl dose not support the rotate option, and when it was removed, but you are not the only one effected by this, and there are open bug report for this on launchpad.

  • Bug #1450770 “logrotate action “rotate” failed”
  • Bug #1476296 “Nginx 1.8 (stable PPA) service commands don't work...”

As mention by other answers above&below, you can edit the nignx logrotate file and replace the problmatic line

invoke-rc.d nginx reload >/dev/null 2>&1

with other alternatives which works,

start-stop-daemon --stop --signal USR1 --quiet --pidfile /run/nginx.pid --name nginx
# or 
service nginx rotate >/dev/null 2>&1
# or
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`

What ever method you chose, please not that you are changing a file which is manage by a package, and after you change it, It won't be updated any more and you'll have to manually resolve the diff or overwrite it with a new one(which all ready include the fix).