bash – Docker:Cronjob无法正常工作

前端之家收集整理的这篇文章主要介绍了bash – Docker:Cronjob无法正常工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

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文件

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

有谁遇到过这个问题?如果是的话,请你指点一下吗?

提前致谢.

最佳答案
LXC容器不是虚拟机.你需要在前台明确地运行cron守护进程.更好的是仍然从Supervisorrunit等程序运行cron.

参考: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.

原文链接:https://www.f2er.com/docker/437110.html

猜你在找的Docker相关文章