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

          主站蜘蛛池模板: 五河县| 绥德县| 温宿县| 澄城县| 高密市| 裕民县| 迁安市| 闵行区| 普兰店市| 安国市| 额济纳旗| 正定县| 阿克| 徐闻县| 青冈县| 依安县| 卓尼县| 平原县| 张北县| 定安县| 青冈县| 洛隆县| 乌拉特后旗| 临海市| 驻马店市| 双江| 尚义县| 泰兴市| 抚松县| 淅川县| 通城县| 炉霍县| 布拖县| 武川县| 玉屏| 元谋县| 耒阳市| 林口县| 扎鲁特旗| 乐亭县| 广元市|