Problem starting a program from a script via crontab
Hi all
I am running a Mythtv frontend, if mythfrontend crashes I want to restart it automatically. I have the following script which works when run from the command line './mythfrontend_restart.sh'. However when I add the line to my crontab * * * * * /home/mythuser/mythfrontend_restart.sh nothing happerns. I know the script is getting ran as I have fed the output into a text file, it seems to ignore the 'mythfrontend' command.
#!/bin/bash
pidno=$( ps ax | grep mythfrontend.real | grep -v grep | grep -v mythmon)
# echo $pidno
# Checks for pid in "ps" listing, field #1.
# Then makes sure it is the actual process, not the process invoked by this scr$
# The last "grep $1" filters out this possibility.
if [ -z "$pidno" ] # If, after all the filtering, the result is a zero-length $
then # no running process corresponds to the pid given.
echo "No such process running."
mythfrontend
exit $E_NOSUCHPROCESS
fi
Any help gratefully received.
Regards
Stefan
|