Hi, I have problems with newcs, and I need a check and restart script for newcs via cron. This script need to check newcs every 5 minuts and if it down, to restart it.
I try to do it with this script:
#!/bin/bash
if ps -ef | grep newcs | grep -v grep ; then
echo && date>> /var/log/newcs.ok
else
/usr/local/bin/newcs &
echo && date>> /var/log/newcs.restart
fi
I named this script newcscheck.sh and gave atributes 755
and I add a cronjob:
*/1 * * * * /var/script/newcscheck.sh
What's wrong?
Thanks in advance
C/P
#!/bin/sh
if ps x |grep -v grep |grep -c newcs >/dev/null
then
echo "newcs... ok"
else
date=`date`
echo "Restarting newcs : $date" >> /tmp/lognewcs.txt
echo "newcs... restarting"
/usr/bin/newcs -b >>/tmp/lognewcs.txt &
fi
C/P
The script i use is witn name/location /etc/chkncs :
#!/bin/bash
if ps -ef | grep newcs | grep -v grep ; then
#The process is running, bring it to the front
echo "Newcs is running"
echo && date >> /var/log/newcs.ok
exit 0
fi
#The process is not running, start it
echo "Newcs startes"
echo && date >> /var/log/newcs.check
newcs
And in "crontab -e"
Run evry 5 min.
# m h dom mon dow command
*/5 * * * * /etc/chkncs
(https://www.cardsharing-x.com/proxy.php?request=http%3A%2F%2Fimg37.imageshack.us%2Fimg37%2F3730%2Fnewcs.jpg&hash=e8a3bd51ac3cac02fcdea991029e0fbbc4a077c5)
this is the image with this command, how to make the script, and how to add this script to running periodicaly with crontab ?
Thanks, script work like charm
Good work