crontab 例子

 一个简单的 crontab 示例
0,20,40 22-23 * 7 fri-sat /home/ian/mycrontest.sh

在这个示例中,我们的命令在 7 月的每个星期五和星期六晚上 10 点到午夜之间的第 0、20、40 分钟(每 20 分钟)执行。关于指定时间的其他方式的细节,参见 crontab(5) 的手册页。

例子:

#检查公司IP
*/10 * * * fri-sun /home/ubuntu/check_ip.sh

周五到周日每隔10分钟,检查下ip变化情况。

帮助文档屏率部分关键解释:

wade@V1088:~$ man 5 crontab

field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

A field may be an asterisk (*), which always stands for ``first-last''.

Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen.
The specified range is inclusive. For example, 8-11 for an ``hours'' entry
specifies execution at hours 8, 9, 10 and 11.

Lists are allowed. A list is a set of numbers (or ranges) separated by commas.
Examples: ``1,2,5,9'', ``0-4,8-12''.

原文地址:https://www.cnblogs.com/no7dw/p/3917172.html