After I built this site with nginx and spawn-fcgi, the process of spawn-fcgi crashed for several times, and I have no idea about how it happend. So I decided to write a shell script to check if the process is still running and use crontab to run this script regularly.
Create the shell script “/usr/bin/check-fastcgi”:
#!/bin/bashtimestr=`date`echo $timestr:>>/srv/www/log/fcgi.logstatus=`netstat -anut | grep 127.0.0.1:9000`if [ "$status" ]; thenecho “fastcgi: running”>>/srv/www/log/fcgi.logelsecmdStr=`/etc/init.d/init-fastcgi restart`echo $cmdStr>>/srv/www/log/fcgi.logfi
Make script executable:
chmod +x /usr/bin/check-fastcgi
Then create a crontab file “crontab_check”:
x/5 x x x x check-fastcgi
This sentence means to run the script every five minutes. Add it to cron schedule:
crontab crontab_check
It’s done. Use “crontab -l” to check the schedule list and there was a new task I just added.

0 Comments.