- 论坛徽章:
- 6
|
回复 6# zhzhs
[root@localhost sh]# cat task.lst
30 0 * * * /report/del_expired_file.sh
0,10,20,30,40,50 * * * * /report/go_control.sh
[root@localhost sh]#
[root@localhost sh]# awk -v d=`date +%d` -v M=`date +%M` -v H=`date +%H` -v m=`date +%m` -v z=`date +%w` '$1!="*"{gsub(/^0,/,"00,");gsub(/,/,"|");if(M!~$1){next}} $2!="*"{if(H!~$2){next}}$3!="*"{if(d!~$3){next}}$4!="*"{if(m!~$4){next}}$5!="*"{if(z!~$5){next}} {print $6}' task.lst
/report/go_control.sh
[root@localhost sh]#
[root@localhost sh]#
[root@localhost sh]# date
Thu Dec 5 15:50:33 CST 2013
[root@localhost sh]#
[root@localhost sh]#
[root@localhost sh]# awk -v d=`date +%d` -v M=`date +%M` -v H=`date +%H` -v m=`date +%m` -v z=`date +%w` '$1!="*"{gsub(/^0,/,"00,");gsub(/,/,"|");if(M!~$1){next}} $2!="*"{if(H!~$2){next}}$3!="*"{if(d!~$3){next}}$4!="*"{if(m!~$4){next}}$5!="*"{if(z!~$5){next}} {print $6}' task.lst
[root@localhost sh]# date
Thu Dec 5 15:51:23 CST 2013
[root@localhost sh]#
不是系统时间符合条件出第六段吗。 |
|