# Script in /etc/periodic/daily does not run automatically



## ractive (Feb 19, 2009)

Hello everyone

On a FreeBSD 7.1 installation, I created a script /etc/periodic/daily/600.svn-hotcopy with the same permissions and ownership as the other script in this folder.

When I run "periodic daily" manually from the command line, the script is executed and works as expected. During the night, when cron runs "periodic daily", the script is not executed.

Any ideas what I am missing?


Regards

James


----------



## DutchDaemon (Feb 19, 2009)

When a script runs from the command line but not from cron, it's almost always a matter of not using either a PATH setting in cron (cron has a limited path) or not writing full paths to executables in your script.


----------



## ractive (Feb 20, 2009)

The shebang line of a python script I called in my script contained

```
#!/usr/bin/env python
```
which seems to use environment settings cron does not have. So I changed it to #!/usr/local/bin/python and it works now.

I found this out in daily.log which I enabled in /etc/periodic.conf (after I copied /etc/defaults/periodic.conf to /etc):

```
daily_output="/var/log/daily.log"
```


Thanks for your help.


----------



## DutchDaemon (Feb 20, 2009)

If you don't want to be bitten by this again, I recommend setting something like

PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

at or near the top of your root crontab.

The default PATH is PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin


----------



## trev (Feb 20, 2009)

Beware the security implications of setting /usr/local paths in root crontabs.


----------



## carlton_draught (Apr 22, 2010)

trev said:
			
		

> Beware the security implications of setting /usr/local paths in root crontabs.


Sorry to resurrect the thread, but could you elaborate on this? /usr/local/bin and /usr/local/sbin directories and files are only writeable by root, so I'm struggling to see where the exploit is.


----------

