基于centos7系统定时任务创建
1.安装定时任务
yum install crontabs
2.设置开机自动重启
systemctl enable crond systemctl start crond
3.编辑定时任务
vim /etc/crontab
定时任务规则:
* * * * * command 分 时 日 月 周 命令 第1列表示分钟1~59 每分钟用*或者 */1表示 第2列表示小时1~23(0表示0点) 第3列表示日期1~31 第4列表示月份1~12 第5列标识号星期0~6(0表示星期天) 第6列要运行的命令 例: 30 22 * * * pm2 restart 2 表示每晚的22:30执行命令 50 5 2,9,22 * * pm2 restart 2 表示每月2、9、22日的5 : 50执行命令 00 00 * * 5,0 pm2 restart 2 表示每周5、周日的00 : 00执行命令 0,50 17-23 * * * pm2 restart 2 表示在每天17 : 00至23 : 00之间每隔15分钟执行命令 0 23 * * 6 pm2 restart 2 表示每星期六的晚上11 : 00执行命令 * */1 * * * pm2 restart 2 每一小时执行命令 * 22-7/1 * * * pm2 restart 2 晚上10点到早上7点之间,每隔一小时执行命令 0 6 1 jan * pm2 restart 2 一月一号的6点执行命令
4.重启定时任务生效
crontab /etc/crontab
5.查看定时任务列表
crontab -l
下一篇:
SQL Server常用的几种启动方式