cron and a dosemu session
I'm running a hamradio system under DOSEmu and have been trying to get cron to restart it if it crashes. I've written a shell script that works PERFECT if I run it manually, however if cron attempts to execute it, somehow it fails to restart the process.
My cron line is: */5 * * * * root /usr/local/bin/noscheck My noscheck script is: #! /bin/sh GOOD=`fping nos.n1uro.ampr.org |awk '{print $3}' ` PID=`ps ax|grep dos|grep nos|awk '{ print $1}' ` if [ -z $PID ]; then echo "MFNOS is $GOOD, resetting..." su -c /home/n1uro/n n1uro & sleep 30 fping nos exit 0 fi if [ $GOOD != alive ]; then echo "MFNOS is $GOOD, resetting..." PID=`ps ax|grep dos|grep nos|awk '{print $1}' ` kill -9 $PID su -c /home/n1uro/n n1uro & sleep 30 fping nos exit 0 fi echo "MFNOS is $GOOD" exit 0 fi exit 0 and finally the 'n' script is: #!/bin/sh cd /path/to/n sudo ip route add x.x.x.x via y.y.y.y dev sl0 table 1 setuid user sudo nice -19 dosemu -f /etc/dosemu/nos.conf -d -n exit 0 Sometimes the program simply hangs and dosemu doesn't exit (note: I'm running 2 concurrent DOSEmu sessions so capturing the right pid is important). Again if I run it manually it's perfect and the session reloads. Via cron however, it fails... any ideas? I'm pretty stumped on this one. |
cron has its own environment, therefore probably your commands are simply not found. You need to set PATH or use full path.
also insert set -xv at the beginning of the script to see what's happening and redirect stdout and stderr into files. |
Actually the whole process is quite deep and requires an actual user to execute it.
I was able to trace the processes of each script days ago and realized that this as it is will be impossible. I'll need to research another way. |
Because of the nature of the sequence of tasks, it's impossible to reach the goal of this being a working cronjob.
|
Marking as resoloved just to close this thread.
|
All times are GMT -5. The time now is 04:30 PM. |