Remember the path young Padawan

Always remember to use the complete path in your CRON scripts.  The script below will check to see if your server can ping a router, if it fails it will restart your network.  This scripts works on Red Hat based Linux systems like CentOS and Fedora.

#!/bin/bash

ROUTER_IP=XXX.XXX.XXX.XXX

( ! /bin/ping -c1 $ROUTER_IP >/dev/null 2>&1 ) && /etc/rc.d/init.d/./network restart


I am posting this to my blog as a reminder to myself (and others if this shows up in a search) to always use the full path to files when you use them in a CRON.  You can always run the script the command line as some user and it will work.  When you put it in the CRON it will fail.



What the heck is a Padawan?

Popular posts from this blog

Reverse Flow Smoker

Moana Review