I just switched to an Ubuntu 14.04 server from an 11.04 server. In /var/spool/cron/crontabs/root I have the line:
* * * * * /root/arewerunning.sh > /root/appmon.log
arewerunning.sh looks like this:
#!/bin/sh if P=$(pgrep aserver) then echo " " else echo "aserver has stopped. System Will reboot" sudo reboot now fi
On the 11.04 server this was working. Whenever I killed aserver the system would reboot. But on 14.04 the command appears to be running but the system does not restart. cron.log looks like:
(root) CMD (/root/arewerunning.sh > /root/appmon.log)
when the process hasn't been killed and like:
(root) CMD (/root/arewerunning.sh > /root/appmon.log) (CRON) info (No MTA installed, discarding output)
when the process has been killed. I know that the MTA line is because it is trying to email me and it can't, but that shouldn't prevent the reboot.
I have tried running the command outside of cron and it works just fine. I'm using a direct path so that shouldn't be a problem. I have also tried adding "sh" in front of the command. appmon.log isn't showing anything. I've tried putting other commands in the file and they work just fine.