Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how can i restart spawn-fcgi on nginx server?

share|improve this question

Run it with option -P to store the PID in some temp file. For example:

/usr/local/bin/spawn-fcgi -a -p 9000 -P /var/run/ 

Then you can kill it by this pid:

kill -9 `cat /var/run/`
share|improve this answer
And make sure that PID file is writable by spawned process (if you're using -u/-g options) or it will be empty – sendmoreinfo Aug 12 '12 at 13:22

Try this:

This should be what you are looking for.

share|improve this answer

How was the process for spawn-fcgi started, was it by a command line (manually) or using a rc-script. In either case you can kill the process by first finding the PID

Use the command ps aux | grep spawn-fcgi to locate the process and the command kill -9 PID

I recommend slashdot's recommendation of using the rc-script to start and end your spawn-fcgi process.

share|improve this answer

Update: This answer randomly failed on me (I'm not sure why) but I'm leaving this here because it might help someone.

killall -9 -w php-cgi

The "-w" waits. Because if you try to (re)start spawn-fcgi too soon (without a delay) spawn-fcgi always gave me error, something like "...already in use." (I don't remember the exact error, sorry.) However, "-w" doesn't work 100% of the time if you plan to put this in cron. After months of random php failures I decided to switch to php-fpm, which has its own unique problems--proceed with caution.

share|improve this answer

I actually prefer to do this kind of process management by using supervisor:

Supervisor will "hang on to your processes": it will restart as necessary, manage the stdout/stderr logging and give you an explicit command for managing the processes without having to mess with PID files etc.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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