How do I start cron on docker ubuntu base?

2019-01-11 09:21发布

I have installed cron via apt-get install cron

Trying to start cron fails (as expected) because of upstart not running.

What is the command line for starting cron properly (i.e. it will read users' crontabs, will read /etc/crontab/* etc)?

Please note that I do not want to start the container as a "full" machine, so I don't want to run /sbin/init or upstart. I manage the processes via supervisord, so what I 'm missing is the command line to add to its configuration file.

2条回答
劳资没心,怎么记你
2楼-- · 2019-01-11 09:35

I just start cron with the plain cron command which will start it as daemon, while I later keep the process of my start script blocking with tail -f <my logfile>.

查看更多
ら.Afraid
3楼-- · 2019-01-11 09:41

You can run cron without daemon mode.

root@xxxxxx:~# cron -f

I was just trying to test it:

  • I started /bin/bash in a new container
  • apt-get install cron nano screen
  • getty tty -a root
  • screen, in screen I created 2 terminals:
  • first: cron -f
  • second: crontab -e - edit your crontab, save and you can watch that the cron is working ...
查看更多
登录 后发表回答