linux定时计划任务crontab是一个精确到分钟的定时计划任务,可以在指定的时间点运行任务。适应那些需要在确定时间点执行的任务。
1.crontab安装
命令:
yum provides crontab
yum install -y cronie
[root@patrolagent cron]# yum provides crontab
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
cronie-1.4.11-17.el7.x86_64 : Cron daemon for executing programs at set times
Repo : rhel7
Matched from:
Filename : /usr/bin/crontab
cronie-1.4.11-17.el7.x86_64 : Cron daemon for executing programs at set times
Repo : @anaconda/7.4
Matched from:
Filename : /usr/bin/crontab
[root@patrolagent cron]# yum install -y cronie
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Package cronie-1.4.11-17.el7.x86_64 already installed and latest version
Nothing to do
[root@patrolagent cron]#
定时计划任务crontab依赖crond守护进程运行,检查确保crontab服务已启动。
命令:
systemctl enable crond
systemctl start crond
systemctl status crond
[root@patrolagent cron]# systemctl enable crond
[root@patrolagent cron]# systemctl start crond
[root@patrolagent cron]# systemctl status crond
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-11-29 08:03:28 CST; 25min ago
Main PID: 789 (crond)
CGroup: /system.slice/crond.service
└─789 /usr/sbin/crond -n
Nov 29 08:03:28 patrolagent systemd[1]: Started Command Scheduler.
Nov 29 08:03:28 patrolagent systemd[1]: Starting Command Scheduler...
Nov 29 08:03:28 patrolagent crond[789]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 57% if used.)
Nov 29 08:03:28 patrolagent crond[789]
标签:crontab,crond,cron,systemctl,linux,定时,root,patrolagent
From: https://blog.csdn.net/z19861216/article/details/144126106