Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having a strange problem about ubuntu crontab here.

If I add the following line to system crontab(/etc/crontab), it works well

*/1 * * * * root /bin/date >> /root/text

but if I edit root crontab by using crontab -e with root user, and add

*/1 * * * * /bin/date >> /root/text

it does not work at all.

Can you please help me on this?

Thank you

update and answer

I got my answer after searching server fault, the reason is explained in this post.

The reason is that crontab file need a newline in the end, otherwise it will not work.

share|improve this question

migrated from stackoverflow.com Oct 9 '12 at 10:38

This question came from our site for professional and enthusiast programmers.

    
Have you used sudo crontab -e' ? To create crontab for root you may need sudo crontab -eu root' –  user268396 Jul 7 '10 at 6:07
    
Probably belongs on serverfault –  Konerak Jul 7 '10 at 6:26
    
I did not use sudo. I actually logged in as root directly –  boblu Jul 7 '10 at 7:39
    
Btw can you tell the difference between */1 and solely * in the first column? –  ott-- Jan 14 '13 at 12:34

2 Answers 2

OP found the solution:

I got my answer after searching server fault, the reason is explained in this post.

The reason is that crontab file need a newline in the end, otherwise it will not work.

share|improve this answer

You may can check if you have /etc/cron.allow and/or /etc/cron.deny files and contents of these files. Here you have excerpt from man page crontab(1):

If the /etc/cron.allow file exists, then you must be listed therein in order to be allowed to use this command. If the /etc/cron.allow file does not exist but the /etc/cron.deny file does exist, then you must not be listed in the /etc/cron.deny file in order to use this command. If neither of these files exists, then depending on site-dependent configuration parameters, only the super user will be allowed to use this command, or all users will be able to use this command. For standard Debian systems, all users may use this command.

share|improve this answer
    
thank you for answering. I just checked whether cron.allow or cron.deny exists in /etc. But I found neither of them there. Is there any other reason why I can not get root crontab working? –  boblu Jul 9 '10 at 13:01
    
According to docs it should work for root user and as I see you found your answer :). But you can always put empty cron.deny file for allow all users to access to the cron or put only allowed users in cron.allow file. I think it will more precise that doesn't have any of these files (in that case the behavior is not consistent between different systems) . –  Lukasz Stelmach Jul 10 '10 at 7:37
    
AFAIK cron.deny and cron.allow do not exist by default in debian based distros. Only centos redhat ship them by default. –  coincoin Jan 14 '13 at 12:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.