(1) at 一次性的计划任务

语法:

# at [参数] [时间]

at> 执行的指令

退出at命令 ctrl+d

[root@localhost ~]# at now
at> mkdir te
at> cp /etc/passwd /te
at> <EOT>

[root@localhost ~]# atq   查询at任务

[root@localhost ~]# atrm  删除at任务

at会把任务放到/var/spool/at目录下。

(2) crontab 周期性的计划任务

语法格式:

[root@localhost ~]# vim /etc/crontab
# Example of job definition:
# .---------------- minute ( - )
# | .------------- hour ( - )
# | | .---------- day of month ( - )
# | | | .------- month ( - ) OR jan,feb,mar,apr ...
# | | | | .---- day of week ( - ) (Sunday= or ) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed [root@localhost ~]# crontab -e -u username #为username创建任务
[root@localhost ~]# crontab -l -u username #列出任务
[root@localhost ~]# crontab -r -u username #删除任务 * * * * * /bin/echo hello
*/ * * * * /bin/echo hello #每隔一分钟

(3) anacron

也是Linux系统中的调度工具,与cron很类似(可每天、每周或每月周期性地执行),但也有不同:

- 执行cron的系统必须随时保持启动,因为如果在指定的时间主机没有正常启动,则调度的任务就无法执行。

- anacron如果在指定的时间没有成功执行,则会在一段时间进程控制与管理之后再次执行,所以顺利执行的概率较高。

所有的任务都设置在/etc/anacrontab文件中,在这个文件中的每一行都表示一个任务(注释与环境变量例外),它们的格式如下:

时间间隔    等待时间   任务标识   命令

• 时间间隔:执行任务的时间间隔,单位为天。

• 等待时间:在时间间隔到期后,如果任务没有顺利执行,则会等待此处设置的时间,然后再次尝试执行。

• 任务标识:有关此任务的说明,它可包含任何非空格的字符(/除外),通常都用在anacron信息中,或是此任务的时间戳文件名。

• 命令:实际执行的任务。

当任务完成后,anacron会将此日期记录在/var/spool/anacron目录的Timestamp文件中,默认的Timestamp文件有三个:cron.daily,cron.monthly和cron.weekly

[root@localhost ~]# vim /etc/anacrontab
# /etc/anacrontab: configuration file for anacron # See anacron() and anacrontab() for details. SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=
# the jobs will be started during the following hours only
START_HOURS_RANGE=- #period in days delay in minutes job-identifier command
cron.daily nice run-parts /etc/cron.daily
cron.weekly nice run-parts /etc/cron.weekly
@monthly cron.monthly nice run-parts /etc/cron.monthly

最新文章

  1. [教学] Delphi Berlin 10.1 开发 Windows 10 平板 App 远程调试
  2. Windbg使用简明指南
  3. 转mysql 多表 update sql语句总结
  4. 一点一滴学shell-Shell expr的用法 (转)
  5. How to use liftover
  6. UVA 11889 Benefit
  7. 在C语言中以编程的方式获取函数名
  8. Jdk1.6 JUC源码解析(12)-ArrayBlockingQueue
  9. Zigbee Class 直播公告2016-10-10
  10. vector动态数组
  11. 时序图中的生命线与类绑定(EA)
  12. Oracle使用学习笔记(一)
  13. 怎样用git上传代码到github以及如何更新代码
  14. Eclipse中java文件生成jar文件的方法
  15. beta版验收互评
  16. Django-wed开发框架-练习题
  17. 集成Glide4.3.1出错!AbstractMethodError: abstract method &quot;void com.bumptech.glide.module
  18. MYSQL performance
  19. 0.0 配置JAVA环境和Maven环境(W10注意点)
  20. USB设备被识别流程【转】

热门文章

  1. C#读写txt文件的两种方法介绍[转]
  2. Retrofit 简介 wiki 文档
  3. Adapter 适配器模式 MD
  4. IOS中的动画——Core Animation
  5. HDU 4576 Robot (概率DP)
  6. 查看centos当前版本
  7. [Backbone]3. More detail on View
  8. svn自助改动password(PHP脚本实现)
  9. 检查许可证所需的adobe application manager 丢失或损坏
  10. LDA主题模型浅析