cron来自希腊语的chronos(时间)一词。在linux中,通过运行crontab -e就可以设置在特定的时刻自动运行你指定的程序。每个用户的自动运行程序,都放在/var/spool/cron/目录下,以自己用户名命名的文件中。在这些文件中,每一行都设置一个自动指行的命令,以及其运行的时间。每一行都由7个字段构成,相邻的字段以空格相间,每个字段的含义如下:
Field Meaning
1 Minute (0-59)
2 Hour (2-24)
3 Day of month (1-31)
4 Month (1-12, Jan, Feb, etc)
5 Day of week (0-6) 0 = Sunday, 1 = Monday etc or Sun, Mon, etc)
6 User that the command will run as
7 Command to execute
其中,有一些设置技巧:
用*/n表示某字段单位时间内运行n次
可以通过以“,”相隔的一列数字,在表示某字段运行的特定值
可以通过n-m来指定n到m 这个区间
可以用>>logfile 2>&1来将程序运行的输出或错误都写到logfile中
>>/dev/null 2>&1可用丢弃程序运行时的输出或错误
可将几个命令以;相隔用()包括起来
参考文献:
Cron Help Guide
Field Meaning
1 Minute (0-59)
2 Hour (2-24)
3 Day of month (1-31)
4 Month (1-12, Jan, Feb, etc)
5 Day of week (0-6) 0 = Sunday, 1 = Monday etc or Sun, Mon, etc)
6 User that the command will run as
7 Command to execute
其中,有一些设置技巧:
用*/n表示某字段单位时间内运行n次
可以通过以“,”相隔的一列数字,在表示某字段运行的特定值
可以通过n-m来指定n到m 这个区间
可以用>>logfile 2>&1来将程序运行的输出或错误都写到logfile中
>>/dev/null 2>&1可用丢弃程序运行时的输出或错误
可将几个命令以;相隔用()包括起来
参考文献:
Cron Help Guide


偶又回来了.
第一个ps作品
