1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | [root@bogon Shell] # crontab --help crontab: invalid option - - '-' crontab: usage error: unrecognized option Usage: crontab [options] file crontab [options] crontab - n [hostname] Options: - u <user> define user - e edit user's crontab - l list user's crontab - r delete user's crontab - i prompt before deleting - n <host> set host in cluster to run users' crontabs - c get host in cluster to run users' crontabs - s selinux context - x <mask> enable debugging crontab 文件的格式: {minute} {hour} {day - of - month} {month} {day - of - week} {full - path - to - shell - script} o minute: 区间为 0 – 59 o hour: 区间为 0 – 23 o day - of - month: 区间为 0 – 31 o month: 区间为 1 – 12. 1 是 1 月. 12 是 12 月. o Day - of - week: 区间为 0 – 7. 周日可以是 0 或 7. 时程表的格式如下: f1 f2 f3 f4 f5 program 其中 f1 是表示分钟,f2 表示小时,f3 表示一个月份中的第几日,f4 表示月份,f5 表示一个星期中的第几天。program 表示要执 行的程序。 当 f1 为 * 时表示每分钟都要执行 program,f2 为 * 时表示每小时都要执行程序,其馀类推 当 f1 为 a - b 时表示从第 a 分钟到第 b 分钟这段时间内要执行,f2 为 a - b 时表示从第 a 到第 b 小时都要执行,其馀类推 当 f1 为 * / n 时表示每 n 分钟个时间间隔执行一次,f2 为 * / n 表示每 n 小时个时间间隔执行一次,其馀类推 当 f1 为 a, b, c,... 时表示第 a, b, c,... 分钟要执行,f2 为 a, b, c,... 时表示第 a, b, c...个小时要执行,其馀类推 使用者也可以将所有的设定先存放在档案 file 中,用 crontab file 的方式来设定时程表。 Crontab 示例 1. 在 12 : 01 a.m 运行,即每天凌晨过一分钟。这是一个恰当的进行备份的时间,因为此时系统负载不大。 1 0 * * * / root / bin / backup.sh 2. 每个工作日(Mon – Fri) 11 : 59 p.m 都进行备份作业。 59 11 * * 1 , 2 , 3 , 4 , 5 / root / bin / backup.sh 下面例子与上面的例子效果一样: 59 11 * * 1 - 5 / root / bin / backup.sh 3. 每 5 分钟运行一次命令 * / 5 * * * * / root / bin / check - status.sh 4. 每个月的第一天 1 : 10 p.m 运行 10 13 1 * * / root / bin / full - backup.sh 5. 每个工作日 11 p.m 运行。 0 23 * * 1 - 5 / root / bin / incremental - backup.sh cron的调度文件有: 1. crontab 2. cron.d 3. cron.daily 4. cron.hourly 5. cron.monthly 6. cron.weekly |
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
· 全程使用 AI 从 0 到 1 写了个小工具