PDA

View Full Version : Script in /etc/periodic/daily does not run automatically


ractive
February 19th, 2009, 18:00
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
February 19th, 2009, 18:33
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
February 20th, 2009, 14:28
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
February 20th, 2009, 15:20
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
February 21st, 2009, 00:57
Beware the security implications of setting /usr/local paths in root crontabs.

carlton_draught
April 22nd, 2010, 09:02
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.