1.定时任务基本概述
1.什么是crond
crond就是计划任务,类似于我们平时生活中的闹钟。定点执行。
2.为什么要使用crond
crond主要是做一些周期性的任务,比如: 凌晨3点定时备份数据。比如:11点开启网站抢购接口,12点关闭网站抢购接口。
3.计划任务主要分为以下两种使用情况:
1.系统级别的定时任务: 临时文件清理、系统信息采集、日志文件切割
2.用户级别的定时任务: 定时向互联网同步时间、定时备份系统配置文件、定时备份数据库的数据
2.定时任务时间管理
1.Crontab配置文件记录了时间周期的含义
[root@oldboy ~]# vim /etc/crontab
SHELL=/bin/bash #执行命令的解释器
PATH=/sbin:/bin:/usr/sbin:/usr/bin #环境变量
MAILTO=root #邮件发给谁
# 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 #星期
# | | | | |
# * * * * * command to be