神剑山庄资源网 Design By www.hcban.com

相信很多人看完docker容器, 需要加crontab, 加完却发现不能执行,心塞.....接着便开始各种折腾...

首先当然是看日志了, 发现/var/log 下面没有任何信息, 那是因为你没有打开rsyslog.

# /etc/init.d/rsyslog start

继续看日志

# tail /var/log/crond
Dec 29 16:39:01 web01-50794 crond[2839]: (root) FAILED to open PAM security session (Cannot make/remove an entry for the specified session)
Dec 29 16:40:01 web01-50794 crond[2842]: (root) FAILED to open PAM security session (Cannot make/remove an entry for the specified session)
Dec 29 16:40:01 web01-50794 crond[2841]: (root) FAILED to open PAM security session (Cannot make/remove an entry for the specified session)
Dec 29 16:41:01 web01-50794 crond[2846]: (root) FAILED to open PAM security session (Cannot make/remove an entry for the specified session)
# tail /var/log/secure
Dec 29 16:39:01 web01-50794 crond[2839]: pam_loginuid(crond:session): set_loginuid failed
Dec 29 16:40:01 web01-50794 crond[2841]: pam_loginuid(crond:session): set_loginuid failed
Dec 29 16:40:01 web01-50794 crond[2842]: pam_loginuid(crond:session): set_loginuid failed
Dec 29 16:41:01 web01-50794 crond[2846]: pam_loginuid(crond:session): set_loginuid failed
# tail /var/log/crond
Dec 29 16:39:01 web01-50794 crond[2839]: (root) FAILED to open PAM security session (Cannot make/remove an entry for the specified session)
Dec 29 16:40:01 web01-50794 crond[2842]: (root) FAILED to open PAM security session (Cannot make/remove an entry for the specified session)
Dec 29 16:40:01 web01-50794 crond[2841]: (root) FAILED to open PAM security session (Cannot make/remove an entry for the specified session)
Dec 29 16:41:01 web01-50794 crond[2846]: (root) FAILED to open PAM security session (Cannot make/remove an entry for the specified session)
# tail /var/log/secure
Dec 29 16:39:01 web01-50794 crond[2839]: pam_loginuid(crond:session): set_loginuid failed
Dec 29 16:40:01 web01-50794 crond[2841]: pam_loginuid(crond:session): set_loginuid failed
Dec 29 16:40:01 web01-50794 crond[2842]: pam_loginuid(crond:session): set_loginuid failed
Dec 29 16:41:01 web01-50794 crond[2846]: pam_loginuid(crond:session): set_loginuid failed

从crontab的日志可以看出是因为pam的原因无法建立一个session连接.

接着看secure日志, 报出了set_loginuid failed , 无法获取用户uid.

分析:

为什么在docker里面无法获取uid"color: #ff0000">解决方案:

# cat /etc/pam.d/crond 
account  required  pam_access.so
account  include  password-auth
#session  required  pam_loginuid.so #注释此行
session  include  password-auth
auth    include  password-auth
# cat /etc/pam.d/crond 
account  required  pam_access.so
account  include  password-auth
#session  required  pam_loginuid.so #注释此行
session  include  password-auth
auth    include  password-auth

以上所述是小编给大家介绍的docker容器中crontab无法正常运行解决方案,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

标签:
docker,crontab

神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网 免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com

评论“docker容器中crontab无法正常运行解决方案”

暂无docker容器中crontab无法正常运行解决方案的评论...