crontab 的一些例子


1. 这个可以的,bi-weekly的task

00 08 * * 3 /home/user/user.script

然后在script的开始写上

if [[ $(expr `date +%W` % 2) = 0 ]]; then
exit
fi


2. 每个月第一周的周三

#!/bin/bash

DATE=`date +%d`

if [ "$DATE" -le "7" ]; then
  run my commands
fi

exit

22 09 * * 3 /path/to/call_me_from_cron


3. 每个月最后一个周三执行

很强大的一个帖子

http://www.ibm.com/developerworks/cn/aix/library/au-eventtime.html

30 11 * * 3 /home/ywywyang/patent/patent_meeting_notify.sh

#/bin/bash
this_month_last_wed=`ncal | grep We | awk '{print $NF}'`
current_date=`date +%d`
if [[ $current_date -eq $this_month_last_wed ]]; then
your script
fi

后来发现有的系统上没有ncal 只有cal 我又改了下script

#/bin/bash
date=`cal | awk '{print $4}'`
this_month_last_wed=`echo $date | awk '{print $NF}'`
current_date=`date +%d`
if [[ $current_date -eq $this_month_last_wed ]]; then
your script
fi

4. 定时 弹出一个框

30 11 * * * DISPLAY=:0.0 zenity --info --text="take a rest"
00 18 * * * DISPLAY=:0.0 zenity --info --text="go home"



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值