cron job

Matthew Seaman m.seaman at infracaninophile.co.uk
Sat Mar 29 07:45:57 PST 2003


On Sat, Mar 29, 2003 at 05:09:01PM +0100, Martin Tsanov wrote:
> Hello
> 
>     I have a gateway with wireless interface wi0. From time to time it hangs down
> with the following log entry in /var/log/all.log
> 
> Mar 28 22:19:37 morpheus /kernel: wi0: failed to allocate 1594 bytes on NIC
> Mar 28 22:19:37 morpheus /kernel: wi0: tx buffer allocation failed
> Mar 28 22:19:37 morpheus /kernel: wi0: wi_cmd: busy bit won't clear.
> Mar 28 22:19:37 morpheus /kernel: wi0: failed to allocate 1594 bytes on NIC
> Mar 28 22:19:37 morpheus /kernel: wi0: mgmt. buffer allocation failed
> Mar 28 22:20:42 morpheus /kernel: wi0: wi_cmd: busy bit won't clear.
> Mar 28 22:21:42 morpheus /kernel: wi0: wi_cmd: busy bit won't clear.
> 
>     I tried the following script, placed as a crontab entry to reboot the system:
> 
> #!/bin/sh
> 
> result=`fping 212.50.x.xxx|cut -b 17-21`
> result1="alive"
> if [ "$result1" = "$result" ]; then
> echo $result
> else
> reboot
> fi
> 
> This script works as expected when envoked from the shell, but when placed
> as th following crontab entry:
> 
> */10    *       *       *       *       root    /root/reb (reb is the script name)
> 
> the system reboots regardless if 212.50.x.xxx is reachable or not.
> 
> What is the difference??? And what am I doing wrong??

Scripts run from cron(8) don't get anything like the environment
settings you have when you try running the script from your login.
Specifically, you need to explicitly set the path to include
/usr/local/bin or the fping command won't be found.  Add:

PATH=/bin:/usr/bin:/usr/local/bin ; export PATH 

up at the top of the script.

	Cheers,

	Matthew


-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030329/4c4212c3/attachment.bin


More information about the freebsd-questions mailing list