Hi,
I have a script that that is supposed to send me an e-mail when a host is not responding to ping:
#!/bin/bash
/bin/ping -c 1 -w 5 myhost.mynetwork.intra &>/dev/null
if [ $? -ne 0 ] ; then
/usr/bin/mailx -s "Server down "
john.doe@domain.com < ./status.txt
fi
The script works fine when I execute it directly but when cron executes it, the ping error is never picked up by the script so the if statement is ignored.
What have I done wrong?
Crontab entry:
*/1 * * * * /home/user/scripts/checkstatus.sh >/dev/null 2>&1