SLES 10.3 Run shell script from cron to restart service
I have a script that checks for a process (by returning a simple pgrep value), if it doesn't find the pid, it will restart the service.
This code works great from within shell with a simple ./FILENAME.sh
# ndsd restart command
# path to pgrep
# find ndsd pid
if [ $? -ne 0 ]
echo "NDS has been restarted." | mail -s 'Server NDS Crash' insert_email
It will check for the pid, if not found, it WILL restart it.
The issue I have, is when it is being run from cron, it will not restart the service.
The script runs in cron. I can tell because I get the email saying that it has crashed, but it does not start it back up.
Also, since it does not restart, I get numerous emails (one for each time the job runs in cron. Every 5 minutes).
As a matter of fact, I have ran multiple different shell scripts from cron, and none will start/stop/restart any service. Is there something I'm missing?