Docker:Cronjob 不工作 [英] Docker: Cronjob is not working

查看:20
本文介绍了Docker:Cronjob 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Docker 容器上运行 cron 作业.我有一个正在运行的容器(Fedora 20).我还在容器中安装了 cron 包并显式运行 cron 守护进程.我还检查了 cron.deny 文件,它是空的,并且/etc/目录下没有名为 cron.allow 的文件.

I am trying to run cron job on Docker container. I have a running container (Fedora 20). I have also installed cron packages in container and explicitly run the cron daemon. I have also checked cron.deny file it is empty and there is no file called cron.allow under /etc/ directory.

Whenever I tried to set the cronjob by using crontab -e or trying to list the cron job using 

    crontab -l I am getting following error.

bash-4.2# crontab -l
You (root) are not allowed to access to (crontab) because of pam configuration.


bash-4.2# crontab -e
You (root) are not allowed to access to (crontab) because of pam configuration.

我还检查了/etc/pam.d/crond 文件,它具有以下条目

I also checked the /etc/pam.d/crond file it has following entry

bash-4.2# vi/etc/pam.d/crond

bash-4.2# vi /etc/pam.d/crond

#
# The PAM configuration file for the cron daemon
#
#
# No PAM authentication called, auth modules not needed

account    required   pam_access.so
account    include    password-auth
session    required   pam_loginuid.so
session    include    password-auth
auth       include    password-auth

有人遇到过这个问题吗?如果是的话,你能给我建议一些关于这个的指针吗?

Has any one faced this issue? If yes could you please suggest me some pointer on this?

提前致谢.

推荐答案

LXC 容器不是虚拟机.您需要在前台显式运行 cron 守护程序.最好还是从 Supervisor运行单元.

An LXC container is not a virtual machine. You'll need to explictly run the cron daemon in the foreground. Better still run cron from program like Supervisor or runit.

参考:Docker 文档

传统上,Docker 容器在运行时运行单个进程已启动,例如 Apache 守护程序或 SSH 服务器守护程序.经常尽管您想在一个容器中运行多个进程.有您可以通过多种方式实现这一点,包括使用简单的 Bash脚本作为容器的 CMD 指令的值来安装流程管理工具.

Traditionally a Docker container runs a single process when it is launched, for example an Apache daemon or a SSH server daemon. Often though you want to run more than one process in a container. There are a number of ways you can achieve this ranging from using a simple Bash script as the value of your container's CMD instruction to installing a process management tool.

在这个例子中,我们将使用进程管理工具 Supervisor,用于管理容器中的多个进程.使用Supervisor 使我们能够更好地控制、管理和重启我们要运行的进程.为了证明这一点,我们将安装并管理 SSH 守护程序和 Apache 守护程序.

In this example we're going to make use of the process management tool, Supervisor, to manage multiple processes in our container. Using Supervisor allows us to better control, manage, and restart the processes we want to run. To demonstrate this we're going to install and manage both an SSH daemon and an Apache daemon.

这篇关于Docker:Cronjob 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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