Docker:Cronjob无法正常工作

 国芝翰娥264 发布于 2023-01-01 12:11

我试图在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

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

提前致谢.

1 个回答
  • LXC容器不是虚拟机.你需要在前台明确地运行cron守护进程.更好的还是从Supervisor或runit等程序运行cron .

    参考:Docker文档

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

    在这个例子中,我们将使用流程管理工具Supervisor来管理容器中的多个流程.使用Supervisor可以让我们更好地控制,管理和重启我们想要运行的流程.为了证明这一点,我们将安装和管理SSH守护程序和Apache守护程序.

    2023-01-01 12:13 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有