2009-11-07 17:36:03 +0000 2009-11-07 17:36:03 +0000
72
72
Advertisement

每周用Cron运行一个命令?

Advertisement

简单的问题–我想在每周六上午8:05运行的命令,crontab条目会是什么样的?

Advertisement
Advertisement

答案 (7)

97
97
97
2009-11-07 17:39:51 +0000

这样应该就可以了。

5 8 * * 6 <user> <command>

或者为了可读性

5 8 * * Sat <user> <command>

文件 (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)
```。
22
22
22
2009-11-07 17:41:33 +0000

Sat 8:05AM run find

# Minute Hour Day of Month Month Day of Week Command    
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)                
    5 8 * * Sat /usr/bin/find
```。
12
Advertisement
12
12
2009-11-08 01:33:39 +0000
Advertisement

这些答案都是正确的,如果你以后不知道如何使用cron,可以使用众多【cron生成器】(https://www.google.at/search?q=cron+generators “Google Search for ‘cron generators’”)。

2
2
2
2009-11-07 17:47:04 +0000

通过对 “man 5 crontab "的广泛研究,似乎这样做就可以了:

5 8 * * sat /usr/bin/man 5 crontab

1
Advertisement
1
1
2009-11-07 17:40:20 +0000
Advertisement
5 8 * * 6 *your command*
0
0
0
2012-04-04 01:13:23 +0000

你也可以这样做。

更改crontab:

5 8 * * * <user> cd / && run-parts --report /etc/cron.daily

把你所有的命令脚本放在这个目录下/etc/cron.daily. 确保你已经为它们添加了执行权限。

0
Advertisement
0
0
2009-11-07 17:42:36 +0000
Advertisement

http://www.scrounge.org/linux/cron.html

5 8 * * 6 /usr/bin/foo

…每周六上午8:05运行。

Advertisement