如何在 docker ubuntu 基础上启动 cron? [英] How do I start cron on docker ubuntu base?

查看:40
本文介绍了如何在 docker ubuntu 基础上启动 cron?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过 apt-get install cron

尝试启动 cron 失败(如预期),因为 upstart 没有运行.

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

正确启动 cron 的命令行是什么(即读取用户的 crontab,读取/etc/crontab/* 等)?

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

请注意,我不想将容器作为完整"机器启动,因此我不想运行 /sbin/initupstart.我通过 supervisord 管理进程,所以我缺少的是添加到其配置文件的命令行.

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.

推荐答案

你可以在没有守护进程模式的情况下运行 cron.

You can run cron without daemon mode.

root@xxxxxx:~# cron -f

<小时>

我只是想测试一下:


I was just trying to test it:

  • 我在一个新容器中启动了/bin/bash
  • apt-get install cron nano screen
  • getty tty -a 根
  • screen,在 screen 我创建了 2 个终端:
  • 首先:cron -f
  • 第二个:crontab -e - 编辑你的 crontab,保存,你可以看到 cron 正在工作......
  • 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 ...

这篇关于如何在 docker ubuntu 基础上启动 cron?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆