代码改变世界

crontab作业没有执行案例简单小结

2020-06-11 16:59  潇湘隐者  阅读(1132)  评论(0编辑  收藏  举报

 

案例1:

 

crond服务异常或停止了。或是安装服务后,忘记启动服务。

 

操作系统 Red Hat Enterprise Linux Server release 6.6

 

# yum list cronie
# yum install cronie

 

安装后,没有启动服务,然后作业就没有执行。

 

#  service crond status
crond is stopped
#  service crond start
Starting crond: [  OK  ]

 

案例2:

 

机房空调出现故障,导致IBM存储因温度过高,保护机制被启用,然后linux在写的过程,失去了这个节点,在存储重起后,linux自动连接了存储,但保留的原有的节点,导致文件被改为只读。

 

然后crontab作业全部停止运行了。

 

 

案例3:

 

密码过期后,导致crontab作业没有运行,参考博客Linux账号密码过期会导致crontab作业不能执行。遇到这种情况,应该首先用chage -l user 查看账号密码策略,然后检查日志信息

 

# chage -l root
Last password change                                    : Apr 28, 2020
Password expires                                        : Jun 27, 2020
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 7
Maximum number of days between password change          : 60
Number of days of warning before password expires       : 7

 

一般/var/log/cron中会有类似下面这样的信息

 

May 26 00:00:01 xxxx crond[26322]: (root) FAILED to authorize user with PAM (Module is unknown)

 

 

 

 

案例4:

 

注意配置,例如/etc/cron.deny是否禁止这个账号运行一些crontab作业。还有就是检查是否启用了SELinux,检查配置文件

 

# cat /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
 
# cat /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

 

有时候一些配置的变跟也会导致作业运行不能运行,个人仅仅碰到过一个简单案例,通过重启crond服务解决。很多复杂情况没有遇到过,无法分析到位。不过一般解决的流程:检查crond服务的日志,通过日志的报错信息来判断、定位分析问题。

 

/var/log/cron