NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
PatrikL
Oct 12, 2011Aspirant
Not getting cron to work
I've tried to get a script (importing torrent files from rss) executed once an hour by simply placing it in cron.hourly but nothing whatsoever happens. The script executes well manually when I'm logged in as root and the file permissions are set to exactly the same as the files in cron.daily (since there were none in cron.hourly) but doesnt seem to run. Or does and I havent found the log that says that something went wrong?
Yesterday I moved it to cron.daily to see if that works better but no luck...
Any idea to what I am doing wrong? Do I need to register my script file somewhere as well as putting it into one of the cron directories?
Cheers
Edit: This is on a ReadyNas Ultra 2, bought a few weeks ago and updated to the latest firmware since then
Yesterday I moved it to cron.daily to see if that works better but no luck...
Any idea to what I am doing wrong? Do I need to register my script file somewhere as well as putting it into one of the cron directories?
Cheers
Edit: This is on a ReadyNas Ultra 2, bought a few weeks ago and updated to the latest firmware since then
25 Replies
Replies have been turned off for this discussion
- sphardy1ApprenticeWhen you run from commandline, what is the command you use?
- PatrikLAspirantI just execute it like any script or program. In this particular case it is:
/etc/cron.daily/import_ssh.py
This is a python script if that makes any difference? - sphardy1ApprenticeIs the header configured correctly to call python?
Any path dependencies that could cause the script to fail?
Can you add debug statements to determine if the script actually runs and fails or doesn't run at all? Or check the cron log
IIRC cron calls the script as just "import_ssh.py" without any path prefix - PatrikLAspirantWell I'm at work and havent configed my firewall to let me in so I can't check it just yet but I can say that the script can be called from anywhere as doesnt use any relative paths.
The headers should be ok, otherwise I shouldnt be able to run it manually either should I?
I'll try to find the cron log (didnt know there was one tbh) and see if it says anything. Is cron run as root btw or another user? If another user it could be the case that it can't open the files it is trying to open...
Thanks for the help so far! - sphardy1ApprenticeJobs are run as root
- PatrikLAspirantOk added a simple write one line to a file (absolute path) with date+time. Its in the top of the script to make sure its done before anything else can go wrong. Neither my scripts debug log line nor the cron log has any info what so ever about running my script. Not sure how to proceed...
- sphardy1ApprenticeIf your script is not being run, there has to be a very basic problem - permissions or script header for example- start with something simple and ensure the script works, then build from there.
- WhoCares_MentorMaybe a stupid question but: did you add a blank line to the end of the cron jobs definition file? If not, give it a try.
-Stefan - PatrikLAspirant
WhoCares? wrote: Maybe a stupid question but: did you add a blank line to the end of the cron jobs definition file? If not, give it a try.
-Stefan
No, didnt know I should have? Just to clarify: I have only places the script in the cron.hourly directory and havent done anything else. No editing of files, nothing.
Tbh this problem isnt nearly as irritating as Transmission crashing on me every 3 minutes but that's a whole different thread... - sphardy1Apprentice/etc/crontab defines the default jobs
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
2 things to note:
1. Scripts placed in the cron.hourly / cron.daily etc directories will be run automatically - no cron updates need be made. You can verify the scripts to be run with the 'run-parts' command
2. They will be run under a standard bourne shell (/bin/sh) so be sure that your script runs fine under that (standard login shell for the root user is bash, not bourne shell)
Related Content
NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!