Has anyone written a self-watchdog script and can share the way it was resolved? I have DD-WRT on one of the routers and can make only one startup script. The problem is doesn't get run. If I log on by telnet and start it manually it works great. So I need to add a cron rule to run it, but not run more then once. I was thinking about using:
if [`ps | grep [c]ustom.sh` -gt 1]; then
exit;
else
...
fi
Do you know any other way to do this?
You can use a lock that remains in memory (usually /tmp is a tmpfs mount) that will be removed at boot:
I think that the problem is that you do not have the same environment available in your script compared to ssh shell (e.g. PATH...). You should write the output of the script in a log file. Just add this line at the beginning of the script.