Nginx dead but pid file exists

I had this problem a few times, “nginx dead but pid file exists”

My site suddenly can not access, after I typed “service nginx status”
and
the answer is “nginx dead but pid file exists”, what happened to my vps?

if possible, how to make the nginx reload / restart automatically if it
happens again.

Posted at Nginx Forum:

Hi,

I’ve no idea what happened, but may be a look into the error log may
help.

What you can do to prevent this kind of issue is to use monitoring on
that server. I for one use use monit on my servers to make sure services
are running and will be restarted in case a service crashes.

Regards,
Christian

Am 20.10.2012 um 09:55 schrieb “nnttoo” [email protected]:

Can I create a sh file that checks the status of nginx and run it with
cron
job? if nginx status becomes “dead”, then the sh file is going to
restart
nginx. if it can, how to sample his sh file? and how examples of “cron
job”?

Posted at Nginx Forum:

On 20 October 2012 12:36, nnttoo [email protected] wrote:

Can I create a sh file that checks the status of nginx and run it with cron
job? if nginx status becomes “dead”, then the sh file is going to restart
nginx. if it can, how to sample his sh file? and how examples of “cron job”?

If you’re asking for example of how cron jobs work, I don’t think
you’re experienced enough to write scripts to monitor a daemon
robustly.

Please look into “monit” instead, if indeed your VPS environment seems
to kill off processes like nginx randomly. Personally, I’ve never seen
this happen, but I’m sure there are situations in which it can.
Solutions like monit are a band-aid, and not a universal panacea.

Jonathan

Jonathan M. // Oxford, London, UK