crontab:定时任务的守护进程,精确到分,设计秒的我们一般写脚本 -->相当于闹钟
日志文件: ll /var/log/cron*
编辑文件: vim /etc/crontab
进程:ps -ef | grep crond ==> /etc/init.d/crond restart
作用:定时备份,实时备份
常见命令参数
1
2
3
4
5
6
7
8
|
usage:
crontab
[-u user]
file
crontab
[-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e (edit user's
crontab
)
-l (list user's
crontab
)
-r (delete user's
crontab
)
-i (prompt before deleting user's
crontab
)
-s (selinux context)
|
定时任务分类
Linux下的任务调度分为两类,系统任务调度和用户任务调度。
系统任务调度:系统周期性所要执行的工作,比如写缓存数据到硬盘、日志清理等。
在/etc/crontab文件,这个就是系统任务调度的配置文件。
用户任务调度:用户定期要执行的工作,比如用户数据备份、定时邮件提醒等。
用户可以使用 crontab 工具来定制自己的计划任务。
在crontab 文件都被保存在/var/spool/cron目录中。其文件名与用户名一致
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
1.系统定时任务:例如清理系统日志,清理系统缓存 -->不过多的关注
查询系统定时处理任务的路径:
路径1:
cd
/etc/logrotate
.d/ -->可以写定时任务
less
syslog
路径2:
cat
/etc/crontab
-->不推荐使用,但是可以看格式
路径3:
ls
/etc/
|
grep
cron
*
|