Cron Package not running command?

  • Hi All,

    I have a fully working PF Sense implementation, though I have an issue of undetermined origin, which requires me to bounce my WAN interface occasionally (once every week or two).

    I found a script that I have validated works for this purpose, and I have installed the Cron service, with a view to running it every 5 minutes to check if it can ping outside, and if not, bounce the interface.

    The script works perfectly if I run it from diagnostics –> command prompt (using the command```

    The script does not, however, appear to be executed by cron. My cron setup looks like:
    I have also tried chaging the command to```
    sh /usr/local/bin/

    I have executed```
    chmod +x /usr/local/bin/


  • Rebel Alliance Developer Netgate

    When run from Cron, the script won't have a PATH or some other environment variables. Programs called inside the script must use a full path to their executables.

    If you need help checking that, we will need to see the contents of your script.

  • Thanks for the reply. The pingtest script is one that I actually got on here, which seems to be working according to the thread:,17243.msg89348.html#msg89348

    If you prefer not to follow the link, the code is:

    #, v1.0.1
    # Created 2009 by Bennett Lee
    # Released to public domain
    # (1) Attempts to ping several hosts to test connectivity.  After
    #     first successful ping, script exits.
    # (2) If all pings fail, resets interface and retries all pings.
    # (3) If all pings fail again after reset, then reboots pfSense.
    # History
    # 1.0.1   Added delay to ensure interface resets (thx ktims).
    # 1.0.0   Initial release.
    # Set multiple ping targets separated by space.  Include numeric IPs
    # (e.g., remote office, ISP gateway, etc.) for DNS issues which
    # reboot will not correct.
    # Interface to reset, usually your WAN
    # Log file
    while [ $COUNT -le 2 ]
    	for DEST in $ALLDEST
    		#echo `date +%Y%m%d.%H%M%S` "Pinging $DEST" >> $LOGFILE
    		ping -c1 $DEST >/dev/null 2>/dev/null
    		if [ $? -eq 0 ]
    			#echo `date +%Y%m%d.%H%M%S` "Ping $DEST OK." >> $LOGFILE
    			exit 0
    	if [ $COUNT -le 1 ]
    		echo `date +%Y%m%d.%H%M%S` "All pings failed. Resetting interface $BOUNCE." >> $LOGFILE
    		/sbin/ifconfig $BOUNCE down
    		# Give interface time to reset before bringing back up
    		sleep 10
    		/sbin/ifconfig $BOUNCE up
    		# Give WAN time to establish connection
    		sleep 60
    		echo `date +%Y%m%d.%H%M%S` "All pings failed twice. Rebooting..." >> $LOGFILE
    		/sbin/shutdown -r now >> $LOGFILE
    		exit 1
    	COUNT=`expr $COUNT + 1`

    I haven't modified the script, other than to change the IP addresses for pinging to and (Google nameservers), and to change my WAN interface to re1.

  • Rebel Alliance Developer Netgate

    At the very least, ping should be /sbin/ping, and expr should be /bin/expr

    There may be more but I didn't look over every line. You'll need to fix any place that runs a command without specifying the full path.

Log in to reply