简述at和crontab命令

制定 每周三凌晨三、五点10分执行某个脚本,输出当前时间,时间格式为 2017-12-28 10:00:00

at命令:

at [option]…time

  • -l atq 也可以查看计划任务
  • at的作业有队列,用单个英文字母表示,默认都使用a队列
  • -f /somefile 可以指定文件 读取作业任务
  • -d 删除指定的作业,相当于atrm
  • -c 查看指定作业的具体内容
  • -q queue:指明队列;查看任务
  • time:hh:mm[yyyy-mm-dd]
  • noon,midnight,teatime,tomorrow,now+#

crontab命令:

crontab [-u user] [-l] [-e] [-i]

  • -e:编辑任务;
  • -l:列出所有任务
  • -r:移除所有任务;即删除/var/spool/cron/USERNAME文件;
  • -i:在使用-r选项移除所有任务时提示用户确认;
  • -u:user:root用户可以为指定的用户管理cron任务;
  • # 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
    # | | | | |
    # * * * * * user-name command to be executed
  •    10 3,5 * * 3 bash  /tmp/scrips/cron.sh
  • cron.sh
  • #!/bin/bash
    # description:
    # version:0.0.1
    # author:yin wei <8378777618@qq.com>
    # date:
    date “+%F %T”

 

 

 

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/100526

(2)
上一篇 2018-06-07 14:28
下一篇 2018-06-07 15:02

相关推荐

评论列表(1条)

  • 马哥教育
    马哥教育 2018-06-15 08:52

    建议命令和理论区分一下,整理一下格式。