Results 1 to 1 of 1
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. Code: #!/bin/bash # ndsd ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-17-2011 #1
- Join Date
- May 2009
SLES 10.3 Run shell script from cron to restart service
#!/bin/bash # ndsd restart command RESTART="/etc/init.d/ndsd restart" # path to pgrep PGREP="/usr/bin/pgrep ndsd" # find ndsd pid $PGREP if [ $? -ne 0 ] then $RESTART echo "NDS has been restarted." | mail -s 'Server NDS Crash' insert_email fi
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?