# cron job runs, but doesn't do anything



## cracker1985 (Feb 3, 2014)

Hello Sir,

cron starts but doesn't do anything. This my cron job : 
	
	



```
50      23 * * *        /bin/csh /usr/local/etc/sarg/sarg_cron.sh
```

My sarg_cron.sh file :

```
#!/bin/csh

sarg

squid -k rotate
```

How can i fix this? Thank you !


----------



## usdmatt (Feb 3, 2014)

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.


----------



## trh411 (Feb 3, 2014)

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?


----------



## cracker1985 (Feb 4, 2014)

Thank you for answer. I am changed script as following, but problem not fixed :


```
#!/bin/bash



/usr/local/bin/sarg


/usr/local/sbin/squid -k rotate
```

My cron :


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

My /var/log/cron:


```
Feb  4 11:53:02 gammagw /usr/sbin/cron[13907]: (root) CMD (/bin/bash /usr/local/etc/sarg/sarg_cron.sh)
```


----------



## SirDice (Feb 4, 2014)

The shell /bin/bash doesn't exist. This isn't Linux. Always use /bin/sh for (shell) scripting on FreeBSD.


```
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`).


```
53      11 * * *        /usr/local/etc/sarg/sarg_cron.sh
```


----------

