docker ubuntu cron -f is not working

2020-06-03 03:57发布

Trying to run a cron job in a docker container. HAve a supervisord properly configured
(I see cron -f in the ps -ef and if I kill it it respawns)

crontab file (for testing):
* * * * * echo hi >> /root/test

I tried putting it in /etc/cron.d/crontab /etc/crontab and in /var/spool/cron/crontabs/crontab

Nothing is working - I'm not getting anything in /root/test

Any ideas?

1条回答
神经病院院长
2楼-- · 2020-06-03 04:57

You may want to check your crontab syntax; crontab files in places like /etc/crontab require an extra username field, for example:

* * * * * root echo hi >> /root/test

This is documented (not very prominently) in crontab(5):

Jobs in /etc/cron.d/

The jobs in cron.d and /etc/crontab are system jobs, which are used usually for more than one user, thus, additionally the username is needed....

查看更多
登录 后发表回答