I have service named "router" that is able to receive http requests.
I decided to write sh script that will periodically check health of router service.
if something is wrong then it will restart it.
The problem:
if router was started with this script, then if this script is terminated, then router service is also terminated.
strange thing is that simple one-line sh script that simply does "service router restart" - works fine (so it restarts the service and closes immediately and everything is fine)
i suppose the reason is somewhere in loop or some bash if things.
script code attached...
Thanks for help!
#!/bin/bash
while :
do
STATUS=$(curl --silent localhost:80/test)
if [ "$STATUS" != "OK" ]
then
echo "problems: $STATUS".
service router restart
fi
sleep 5
done
continueafterservice router restartto see if it works then to try to isolate the problem.serviceshould fork off the process handling and return once the service has restarted, so all I can think of is that you have written the/etc/init.d/routerscript in a bad way. Post that script as well for anyone to be able to help. – Daniel Andersson Jun 16 '13 at 18:06