最近发现cron无效了
于是输入service crond status发现提示active,代码已经启动
>[root@iZbp1fna7ky0qz2jbj7gfpZ wwwlogs]# service crond status
Redirecting to /bin/systemctl status crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-12-20 22:34:56 CST; 3 days ago
Main PID: 15363 (crond)
CGroup: /system.slice/crond.service
└─15363 /usr/sbin/crond -n
不应该呢?脚本都没有成功执行
于是等了一会
提示
>Dec 20 22:34:56 iZbp1fna7ky0qz2jbj7gfpZ systemd[1]: Stopping Command Scheduler...
Dec 20 22:34:56 iZbp1fna7ky0qz2jbj7gfpZ crond[15363]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 94% if used.)
Dec 20 22:34:56 iZbp1fna7ky0qz2jbj7gfpZ systemd[1]: Stopped Command Scheduler.
Dec 20 22:34:56 iZbp1fna7ky0qz2jbj7gfpZ crond[15363]: (root) `BAD FILE MODE (/var/spool/cron/root)`
Dec 20 22:34:56 iZbp1fna7ky0qz2jbj7gfpZ systemd[1]: Started Command Scheduler.
Dec 20 22:34:56 iZbp1fna7ky0qz2jbj7gfpZ crond[15363]: (CRON) INFO (running with inotify support)
Dec 20 22:34:56 iZbp1fna7ky0qz2jbj7gfpZ crond[15363]: (CRON) INFO (@reboot jobs will be run at computer's startup.)
看来是文件权限设置的不对,于是百度找到解决办法
>chmod 0600 /var/spool/cron/root
service crond restart
成功解决