一.cron
参考:http://www.cnblogs.com/bourneli/archive/2012/04/14/2446944.html
http://blog.csdn.net/ethanzhao/article/details/4406017
1.进入编辑界面
crontab -e
2.第一次进可能需要选择编辑器,以后可以用select-editor再次指定编辑器
3.# m h dom mon dow command
minute (m), hour (h), day of month (dom), month (mon), day of week (dow)
use '*' in these fields (for 'any').
特殊字符 | 代表意义 |
*(星号) | 代表任何时候都接受,比如上面的例子,day,month和week为“*”,表示无论那个月,那一天,周几,都在10点30分执行命令。 |
,(逗号) | 并列时间。举个例子: * 3,6,9,12 * * * command 上面的意思是在3点,6点,9点或12点,执行命令。 |
-(减号) | 连续区间。举个例子: * 9-17 * * * command 上面的意思是从9点到17点,每一分钟都要执行这个任务 |
*/n(斜线) | n代表数组,表示每隔n个单位之间,比如每隔5分钟,可以写成下面 */5 * * * * command |
二.at
参考:http://blog.163.com/xujian900308@126/blog/static/12690761520129911155413/
harryhare@xxx:~/test$ at 15:40
warning: commands will be executed using /bin/sh
at> /home/harryhare/test/hello
at> <EOT>
job 9 at Wed Feb 25 15:40:00 2015
harryhare@xxx:~/test$ at -l
9 Wed Feb 25 15:40:00 2015 a harryhare
harryhare@xxx:~/test$ at -f hello 15:41
warning: commands will be executed using /bin/sh
job 10 at Wed Feb 25 15:41:00 2015
harryhare@xxx:~/test$ at -f hello 15:41 tomorrow
warning: commands will be executed using /bin/sh
job 11 at Thu Feb 26 15:41:00 2015
harryhare@xxx:~/test$ at -l
9 Wed Feb 25 15:40:00 2015 a harryhare
11 Thu Feb 26 15:41:00 2015 a harryhare
10 Wed Feb 25 15:41:00 2015 a harryhare
harryhare@xxx:~/test$ atrm 11
harryhare@xxx:~/test$ at -l
9 Wed Feb 25 15:40:00 2015 a harryhare
10 Wed Feb 25 15:41:00 2015 a harryhare
harryhare@xxx:~/test$ at -r l0
harryhare@xxx:~/test$ at -l
9 Wed Feb 25 15:40:00 2015 a harryhare
三.date输出格式化
参考:http://blog.csdn.net/jk110333/article/details/8590746
date "+%Y_%m_%d_%H_%M_%S"