I have problems with monitoring nginx. Monit can monitor nginx and display resources usage (RAM usage, etc.), but is unable to start/stop nginx. I get only a simple message: "Execution failed". Syslog doesn't tell any more information.

My monitrc configuration file:

check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program  = "/etc/init.d/nginx stop"
group www-data

Restarting any other monitored program (eg. dovecot) works. Also, manually running nginx works

/etc/init.d/nginx start


 May  5 17:47:45 vm7508 monit[7079]: restart service 'nginx' on user request
 May  5 17:47:45 vm7508 monit[7079]: monit daemon at 7079 awakened
 May  5 17:47:45 vm7508 monit[7079]: Awakened by User defined signal 1
 May  5 17:47:45 vm7508 monit[7079]: 'nginx' trying to restart
 May  5 17:47:45 vm7508 monit[7079]: 'nginx' stop: /etc/init.d/nginx
 May  5 17:48:15 vm7508 monit[7079]: 'nginx' failed to stop
 May  5 17:48:15 vm7508 monit[7079]: 'nginx' restart action done


  • The syntax looks correct. Monit is definitely running as root? There are no trailing invisible characters in the monitrc file? – cjc May 5 '13 at 13:14
  • Thanks for your reply, I am sure that monit is running as root, because the monit process (ps aux) belongs to root and also monit is able to start other processes, for example dovecot (what requires root privileges). What do you mean by invisible trailing characters? (also, this is not complete monitrc file, this is only nginx part) @cjc – Matoha May 5 '13 at 13:41
  • I was thinking that the monitrc was edited in Windows, and there are invisible carriage returns at the end of the lines. If you look at it in vim/cat/more/less, they may not be obvious because those utilities handle them correctly, but monitrc may not. Try opening the file with vim -b monitrc. The "-b" option for vim will show non-printable characters. Additionally, are there any useful messages in /var/log/messages or the nginx log? – cjc May 5 '13 at 14:05
  • /var/log/messages: nothing, nginx log: nothing, syslog: see above in the question. The file was editied only on Linux, but I checked it with the vim and found nothing. @cjc – Matoha May 5 '13 at 15:53
  • I have no generic ideas at this point. Did you take a look at this, though? stackoverflow.com/questions/3356476/debugging-monit – cjc May 5 '13 at 17:01

I had same issue but in my case error was clear, the group was mysql instead of www-data (I run nginx on ubuntu) then I change the conf.d file and then restarted the monit and

Process 'nginx' status Running monitoring status Monitored

Hope it helps.

| improve this answer | |

You might want to check if the pid of your process is there or not. Generally it is stored in /var/run/ folder. If the pid file is missing you should manually kill & start the process.

| improve this answer | |

Same issue here (Monit 5.6 from Ubuntu 14.04 LTE package's repository). I don't know exactly what condition you're using to auto restart nginx, but you can do a workaround like so:

check process nginx with pidfile /var/run/nginx.pid
    if <YOUR CONDITION> then exec "/etc/init.d/nginx restart"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.