shell 之 cron,at 和date 格式化输出

一.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"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值