36

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.

rollingBalls
  • 1,808
  • 1
  • 14
  • 25
  • 9
    @matejkramny: That could be, but nobody will do anything different unless you tell them what the right way is. I came here to see if docker is a good way to deploy and isolate something that I need to run daily. – William Pietri Aug 29 '14 at 21:03
  • 4
    @WilliamPietri He just prefers conventions over architecture, because that 's the easy way of achieving mediocre results. How you build your stack depends on exactly what you are doing. The fact that he just spouted his doctrine without asking "why do you do it that way" tells everything. – rollingBalls Aug 29 '14 at 21:38
  • 2
    @matejkramny: Why is that? What's wrong with running cron jobs inside docker? – Karel Bílek Sep 24 '14 at 19:14
  • 4
    nothing, i was suggesting that cron runs in a special container, separated from the web server stuff. Then you can scale web servers without having cron run >1. It came out wrong in the first comment, sorry! See [cron](https://github.com/castawaylabs/lamp-cron) and [lamp-docker](https://github.com/castawaylabs/lamp-docker) – Matej Sep 24 '14 at 19:50
  • @matejkramny how are you rotating your log files? How are you killing zombied child processes? – Jason Apr 13 '15 at 18:42
  • @Jason Supervisor takes care of child processes, and some of my images use papertrail (which utilises rsyslog). Could be better, but works well for me – Matej Apr 13 '15 at 18:54

2 Answers2

38

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 ...
Jiri
  • 16,425
  • 6
  • 52
  • 68
8

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

white_gecko
  • 4,808
  • 4
  • 55
  • 76