tags:

views:

49

answers:

1

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.

A: 

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.

Lukasz Stelmach
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
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