一. 安装 crontabs服务,开机自启:
yum install crontabs
systemctl enable crond
systemctl start crond
可能需要root权限,转root 用户
sudo su -
输入root密码进入
[root@localhost ~]#
二. 自定义定时任务:
vi /etc/crontab编辑
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
*/30 * * * * curl http://www.baidu.com
Ins 插入编辑,ESC退出
: 到编辑器底行,wq保存退出,加!强制退出
三. 保存生效
crontab /etc/crontab
四.查看任务
crontab -l