I have this simple script on crontab (root): (centos 6.5)
if ! ping -c 1 172.20.1.1; then
echo "NOT OK" >> /root/log
ifconfig eth3 down
sleep 5
ifconfig eth3 up
else
echo OK >> /root/log
fi
The script works fine if I run it from directly from terminal and restarts the interfaces but not when run through crontab. I wanted to see if the crontab is actually running as expected and put the echo lines and I'm 100% sure the script is running because I see the OK and NOT OK lines on the log.
What do you think is wrong with this?