:: Cron: Auto restart daemon if it down
:: How to create script for auto restart daemon if it down
+ create auto restart daemon script (nginx)
cat > alwaysup.sh
add the script, like these:
#!/bin/bash
alwaysup=`ps aux | grep -v grep | grep -c nginx`
if [ $alwaysup -le 0 ]
then
/etc/init.d/nginx restart
fi
press ctrl+d for exit
+ make the script executable
chmod +x alwaysup.sh
+ add to cron
crontab -e
*/5 * * * * /root/alwaysup.sh > /dev/null 2>&1