生活随笔
收集整理的這篇文章主要介紹了
解决crontab 定时任务加载失败
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
0x0
- 系統(tǒng):centos7
- 內(nèi)核:3.10.0-1160.15.2.el7.x86_64
今天用crontab創(chuàng)建定時(shí)任務(wù),在測(cè)試時(shí)發(fā)現(xiàn)任務(wù)并沒(méi)有按預(yù)期執(zhí)行,
使用systemctl status crond 查看crond的狀態(tài)
> # systemctl status crond
● crond.service - Command SchedulerLoaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)Active: active (running) since 一 2021-03-08 09:25:57 CST; 7min agoMain PID: 1445 (crond)Tasks: 1CGroup: /system.slice/crond.service└─1445 /usr/sbin/crond -n3月 08 09:25:57 A-boat systemd[1]: Started Command Scheduler.
3月 08 09:25:57 A-boat crond[1445]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 82% if used.)
3月 08 09:25:57 A-boat crond[1445]: ((null)) Unauthorized SELinux context=system_u:system_r:system_cronjob...ntab)
3月 08 09:25:57 A-boat crond[1445]: (root) FAILED (loading cron table)
3月 08 09:25:58 A-boat crond[1445]: (CRON) INFO (running with inotify support)
3月 08 09:25:58 A-boat crond[1445]: (CRON) INFO (@reboot jobs will be run at computer's startup.)
3月 08 09:30:01 A-boat crond[1445]: (*system*) RELOAD (/etc/crontab)
3月 08 09:30:01 A-boat crond[1445]: ((null)) Unauthorized SELinux context=system_u:system_r:system_cronjob...ntab)
3月 08 09:30:01 A-boat crond[1445]: (root) FAILED (loading cron table)
Hint: Some lines were ellipsized, use -l to show in full.
可以看見(jiàn),有一條和SElinux相關(guān)的信息:((null)) Unauthorized SELinux context=system_u:system_r:system_cronjob…ntab)
查詢相關(guān)資料后發(fā)現(xiàn)是被SELinux阻止了
解決方案
執(zhí)行以下命令
chcon -R -usystem_u -robject_r -tsystem_cron_spool_t /etc/crontab
systemctl restart crond
總結(jié)
以上是生活随笔為你收集整理的解决crontab 定时任务加载失败的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。