SUSE Linux Crontab

基本概念

Crontab 类似于Windows 里的task schedule ,是一种定时执行工具 .能够在确定的时间执行确定的任务(脚本)。Crontab 是linux系统里的一个守护进程 ,会随着系统的启动而启动。

基本操作

/sbin/service cron start 启动crontab/sbin/service cron stop 停止crontab/sbin/service cron restart 重新启动crontab/sbin/service cron reload 重新载入crontabcrontab -l (列出当前用户的crontab list)crontab -u root -l (列出root 用户的 list)crontab crontab.txt (载入一个文本文件,替换成当前的crontab list)crontab -e (编辑crontab list)当前激活的 crontab : /var/spool/cron/tabsman 5 crontab 详细帮助信息

在etc下,有以下几个目录,把对应的脚本放入其中,,那么就每隔一段时间执行当前脚本,不需要额外配置/etc/cron.daily /etc/cron.hourly

/etc/cron.monthly

/etc/cron.weekly

参数说明

分 小时 日 月 星期 命令0-59 0-23 1-31 1-12 0-6 command (取值范围,0表示周日一般一行对应一个任务) 特殊符号的含义: “*”代表取值范围内的数字,”/”代表”每”, “-“代表从某个数字到某个数字,”,”分开几个离散的数字

基本流程

导出已有的crontab list , 命令:crontab -u root -l >> crontab.txt编辑 crontab.txt 导入编辑好的文件 :crontab crontab.txt重启cron : /sbin/service cron restart

实际例子

“>#—————————————————- # fields: minute hour day-of-month month day-of-week # Sunday is 7 # More info: man 5 crontab # As root: crontab -l (list current) # crontab crontab.txt (to load changes) # crontab -e (or to edit/replace current) # Active crontab is located in: /var/spool/cron/tabs # # Change log ##————————————————— MAILTO=”xxxx@xxx.com” PATH=/opt/build/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/root/bin: #— New jbe log ————————————————- 30 23 * * 5 /opt/build/bin/jbe_restart >> /opt/build/logs/cron.log 2>&1 #— Keep GSA mounted ——————————————– */15 0-19 * * * /opt/build/bin/gsa_chkmount >> /opt/build/logs/cron.log 2>&1 */15 20-23 * * 0-4,6 /opt/build/bin/gsa_chkmount >> /opt/build/logs/cron.log 2>&1 #— BSO bust-out ———————————————— 0 5,18 * * * ruby /opt/build/bin/appease_bso >> /opt/build/logs/cron.log 2>&1 @reboot ruby /opt/build/bin/appease_bso >> /opt/build/logs/cron.log 2>&1

绚丽的民族风情,悠久的历史文化。抛开尘世的纷扰,

SUSE Linux Crontab

相关文章:

你感兴趣的文章:

标签云: