Ubuntu - Cron jobs don't run

Associate
Joined
19 Jun 2003
Posts
1,680
Location
West Yorks, UK
Hi all,

Got a Ubunutu 6.06 server running. I have some jobs to Crontab for root to run every day at 9am. The jobs in question are scripts stored in /scripts, with chmod a+x permissions, chowned by root:root. For some reason though, they don't run. I have restarted cron, and the server has even been rebooted since, but no joy.

The scripts do very basic things, such as "du -hs *" in a particular folder. Any idea what could be wrong?

Matt
 
Yeah, root is enabled, as I can login as root. But perhaps that is unconnected to cron - should I chown all the scripts to my main login instead?

Matt

P.S Top marks for the quick reply!
 
Stupid question but is your cron daemon running/installed right?
 
Humm, chowning stuff to my main login causes problems. I am trying to do "du -hs *" on a folder which contains lots of subfolders, owned by other users. Therefore, my script fails as it doesn't have permission to count the folder sizes :(

Matt
 
have you "chmod a+x scriptname" ?

change the cron to have:

* * 1 * * /path/to/script 2> /var/logs/cron-error

then read the cron-error file to see any error messages.
 
Dj_Jestar said:
have you "chmod a+x scriptname" ?

change the cron to have:

* * 1 * * /path/to/script 2> /var/logs/cron-error

then read the cron-error file to see any error messages.

I've done that...Will wait and see what comes up now :)

When i've chmod a+x something, how come I still need to call "sh scriptname" to execute it?

Matt
 
Because it needs to be in your $PATH otherwise (ie /usr/bin/ etc..) to be able to just be called by name. Maybe you have missed off #!/bin/sh off the script header as well.
 
Last edited:
Una said:
Because it needs to be in your $PATH otherwise (ie /usr/bin/ etc..) to be able to just be called by name. Maybe you have missed off #!/bin/sh off the script header as well.

Yep, didn't have the script header bit in any of them. Maybe that might help ;)
 
commands in cron must be called from their full path, e.g. /usr/sbin/du (i dunno if it's actually there without checking).
 
Back
Top Bottom