docker ubuntu cron -f 不工作

docker ubuntu cron -f is not working

正在尝试 运行 在 docker 容器中执行 cron 作业。 正确配置了 supervisord
(我在 ps -ef 中看到 cron -f,如果我杀死它它会重生)

crontab 文件(用于测试):
* * * * * echo hi >> /root/test

我试着把它放在 /etc/cron.d/crontab /etc/crontab/var/spool/cron/crontabs/crontab

没有任何效果 - 我在 /root/test

中没有得到任何东西

有什么想法吗?

您可能需要检查您的 crontab 语法; /etc/crontab 等位置的 crontab 文件需要额外的用户名字段,例如:

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

这在 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....