分享java帶來的快樂

          我喜歡java新東西

          crontab 定時任務執行

          #vi /etc/crontab
          看到下面幾個


          # run-parts
          01 * * * * root run-parts /etc/cron.hourly
          02 4 * * * root run-parts /etc/cron.daily
          22 5 * * 0 root run-parts /etc/cron.weekly
          42 5 1 * * root run-parts /etc/cron.monthly


          在/etc/cron.daily
          下添加一個backup.sh(內容就寫最上面的sh腳本)就會每天執行

          重新啟動crond  

          # /etc/rc.d/init.d/crond restart  


          --------------------------
          看一下crontab 的格式
          第1列分鐘1~59
          第2列小時1~23(0表示子夜)
          第3列日1~31
          第4列月1~12
          第5列星期0~6(0表示星期天)
          第6列要運行的命令

          下面是crontab的格式:
          分 時 日 月 星期 要運行的命令

          這里有crontab文件條目的一些例子:

          30 21 * * * /usr/local/apache/bin/apachectl restart
          上面的例子表示每晚的21:30重啟apache。

          45 4 1,10,22 * * /usr/local/apache/bin/apachectl restart
          上面的例子表示每月1、10、22日的4 : 45重啟apache。

          10 1 * * 6,0 /usr/local/apache/bin/apachectl restart
          上面的例子表示每周六、周日的1 : 10重啟apache。

          0,30 18-23 * * * /usr/local/apache/bin/apachectl restart
          上面的例子表示在每天18 : 00至23 : 00之間每隔30分鐘重啟apache。

          0 23 * * 6 /usr/local/apache/bin/apachectl restart
          上面的例子表示每星期六的11 : 00 pm重啟apache。

          ) */1 * * * /usr/local/apache/bin/apachectl restart
          每一小時重啟apache

          0 23-7/1 * * * /usr/local/apache/bin/apachectl restart
          晚上11點到早上7點之間,每隔一小時重啟apache

          0 11 4 * mon-wed /usr/local/apache/bin/apachectl restart
          每月的4號與每周一到周三的11點重啟apache

          0 4 1 jan * /usr/local/apache/bin/apachectl restart

          posted on 2011-03-23 08:56 強強 閱讀(657) 評論(0)  編輯  收藏 所屬分類: linux 操作系統配置

          主站蜘蛛池模板: 西乌珠穆沁旗| 刚察县| 德格县| 涞源县| 和静县| 武城县| 青龙| 海晏县| 河池市| 唐河县| 松滋市| 大理市| 固始县| 富阳市| 静安区| 沁源县| 曲水县| 康保县| 宝鸡市| 神池县| 万州区| 灵璧县| 陕西省| 巴里| 元阳县| 阿拉善右旗| 厦门市| 武隆县| 浦县| 永城市| 渝中区| 仁化县| 奉节县| 上饶县| 日喀则市| 凤翔县| 枝江市| 九江县| 鞍山市| 新竹县| 东兴市|