一. 简介 作用: 计划任务主要是做一些周期性的任务,目前最主要的用途是定期备份数据
Schedule one-time tasks with at. 一次性调度执行 at Schedule recurring jobs with cron. 循环调度执行 cron Schedule recurring system jobs. 所有计划任务执行中的输出都会以邮件的方式发送给指定用户, 除非重定向 (1)一次性调度执行 at 1)程序安装 在软件所在目录 rpm -ivh at.x86_64 //安装 systemctl start atd //启动 systemctl status atd //查看 Active: active (running) //运行。inactive是不活跃就是没有运行。 2 )语法格式
at <TIMESPEC>
now +5min
teatime tomorrow (teatime is 16:00)
noon +4 days
5pm august 3 2018
(3)循环调度执行 cron
1 )简介
# systemctl status crond.service
# ps aux |grep crond
root 550 0.0 0.0 126300 1648 ? Ss 10:05 0:00 /usr/sbin/crond -n
特点
:crond进程每分钟会处理一次计划任务
2 )语法
** 用户级**:
格式:
语法格式 Job format:
Minutes Hours Day-of-Month Month Day-of-Week Command
0 2 /mysql_back.sh 0 2 14 /mysql_back.sh 0 2 14 2 /mysql_back.sh 0 2 5 /mysql_back.sh //不写月日,仅周生效 0 2 6 5 /mysql_back.sh 0 2 2 5 /mysql_back.sh 0 2 2 6 5 /mysql_back.sh //书写月和日,月或日,月日周均生效
/5 /mysql_back.sh 0 2 1,4,6 /mysql_back.sh 0 2 5-9 * /mysql_back.sh