docker容器中crontab无法正常运行解决方案
(编辑:jimmy 日期: 2024/11/26 浏览:3 次 )
相信很多人看完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无法正常运行解决方案,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
下一篇:Tomcat 热部署的实现原理详解