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

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

问题描述

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

 每当我试图使用crontab -e设置cronjob或尝试使用

列出cron作业crontab -l我收到以下错误。

bash-4.2#crontab -l
由于pam配置,您(root)不允许访问(crontab)。


bash-4.2#crontab -e
由于pam配置,您(root)不允许访问(crontab)。

我还检查了/etc/pam.d/crond文件,

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

 
#cron守护程序的PAM配置文件


#没有调用PAM认证,不需要auth模块

需要帐户pam_access.so
帐户包含password-auth
需要的会话pam_loginuid.so
会话include password-auth
auth include password-auth

有没有人遇到这个问题?

解决方案

/ div>

LXC容器不是虚拟机。你需要明确地在前台运行cron守护进程。更好地从程序运行cron,如主管 runit



参考: Docker文档


传统上,当启动
时,Docker容器运行单个进程,例如Apache守护程序或SSH服务器守护程序。通常
,尽管你想在容器中运行多个进程。有
a方法可以实现这一点,从使用简单的Bash
脚本作为容器的CMD指令的值到安装
a过程管理工具。



在这个例子中,我们将使用进程管理
工具,Supervisor来管理我们容器中的多个进程。使用
Supervisor允许我们更好地控制,管理和重新启动我们要运行的
进程。为了演示这个,我们将安装
并管理SSH守护进程和Apache守护进程。



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.

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

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?

thanks in advance.

解决方案

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.

Reference: Docker documentation

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.

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天全站免登陆