分享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 強強 閱讀(666) 評論(0)  編輯  收藏 所屬分類: linux 操作系統配置

          主站蜘蛛池模板: 大埔区| 临澧县| 家居| 临夏县| 酉阳| 张家界市| 花垣县| 鄂伦春自治旗| 孟州市| 博野县| 建德市| 和硕县| 乌拉特前旗| 永川市| 东光县| 清徐县| 定南县| 日土县| 松桃| 山丹县| 本溪| 石景山区| 诏安县| 神农架林区| 桃源县| 安化县| 辉南县| 和龙市| 酉阳| 綦江县| 宝清县| 宝坻区| 孟村| 通山县| 昭苏县| 三门县| 桐梓县| 合作市| 萝北县| 商丘市| 吴川市|