cron job runs, but doesn't do anything

Hello Sir,

cron starts but doesn't do anything. This my cron job :
Code:
50      23 * * *        /bin/csh /usr/local/etc/sarg/sarg_cron.sh

My sarg_cron.sh file :
Code:
#!/bin/csh

sarg

squid -k rotate

How can i fix this? Thank you !
 
Rule number 1 of writing scripts to run from cron: Use the full path for all commands.

I expect squid lives somewhere like /usr/local/s?bin/squid, and cron isn't configured to look there by default.
 
Don't use /bin/csh for writing scripts. Even simple ones. Use /bin/sh or /bin/bash instead. Perhaps the PATH to sarg and squid are not in PATH? Fully qualify them. Does /var/log/cron provide any insight?
 
Thank you for answer. I am changed script as following, but problem not fixed :

Code:
#!/bin/bash



/usr/local/bin/sarg


/usr/local/sbin/squid -k rotate

My cron :

Code:
53      11 * * *        /bin/bash /usr/local/etc/sarg/sarg_cron.sh

My /var/log/cron:

Code:
Feb  4 11:53:02 gammagw /usr/sbin/cron[13907]: (root) CMD (/bin/bash /usr/local/etc/sarg/sarg_cron.sh)
 
The shell /bin/bash doesn't exist. This isn't Linux. Always use /bin/sh for (shell) scripting on FreeBSD.

Code:
53      11 * * *        /bin/bash /usr/local/etc/sarg/sarg_cron.sh
There's no need to specify /bin/bash here. The first line of the script (called shebang) already takes care of loading the shell. You simply have to mark the shell script as executable ( chmod +x /usr/local/etc/sarg/sarg_cron.sh).

Code:
53      11 * * *        /usr/local/etc/sarg/sarg_cron.sh
 
Back
Top