ubuntu system crontab works, but root crontab does not

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.

Answers


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.


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.


Need Your Help

Interesting Powers Of 2 - algorithm/ Math (from Hackerrank ACM APC)

c algorithm math

I came across a problem from a recent competition.