View Full Version : Ubuntu - crontab

23-11-2009, 08:50 PM

I have a script I'm trying to get to run automatically, just for testing purposes.

The script is:

echo "to_file" >> /etc/cron.d/testtext

My 'crontab -e' output:

# m h dom mon dow command
* * * * * root /etc/cron.d/test.sh

Basically nothing happens and I cannot find any logs for cron in /var/logs/... If I run the script manually './test.sh' it works fine and puts a line 'to_file' into the 'testtext' file.

If I put 'echo "to_file" >> /etc/cron.d/testtext' directly into 'crontab' it works fine.

Anyone have any ideas?

Thanks in advance,


23-11-2009, 11:12 PM
You are trying to run "root" with the argument "/etc/cron.d/test.sh"


# m h dom mon dow command
* * * * * /etc/cron.d/test.sh


-Run cron jobs as a normal user if possible.
-You don't need to put the jobs in cron.d
use /home/user/bin or /root/bin

24-11-2009, 09:01 AM
I 2nd that.

The style you've used in your "crontab -e" line is intended only for the global crontab file (/etc/crontab) to let the system know what user to run the script under. I think using /etc/crontab is discouraged (?) these days anyway (jobs running for a particular user should use their own crontab file).

24-11-2009, 10:45 AM
The reason I wanted to run it as root is that the actual script I want scheduled has a command that needs root privileges to run. I do not want to be prompted for password since this is meant to be automated :)

I did remove the 'root' part from the file and now it seems to be running. Thanks for your help, I didn't realise that the syntax for the global crontab file and 'crontab -e' was different.