Linux中用crontab例行工作安排

來源:互聯網
上載者:User

Linux中用crontab例行工作安排 1.什麼是crontab?周期性的處理待辦事項的守護進程,類死任務計劃。2.crontab命令解析。樣本:0 0 * * 1-5 cd /home/hiperry; ./shutDwon.sh > ./logs/shutDwon.log 2>&1--每天晚上十二點執行自訂的關機指令碼並將日誌資訊寫入到指定記錄檔。命令解析:# .---------------- 分鐘 (0 - 59)# |  .------------- 小時 (0 - 23)# |  |  .---------- 每月中的哪一天 (1 - 31)# |  |  |  .------- 月 (1 - 12) OR jan,feb,mar,apr ...# |  |  |  |  .---- 星期幾 (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# |  |  |  |  |# *  *  *  *  *  將要執行的命令 > 代表重新導向到哪裡,例如:echo "123" > /home/123.txt1 表示stdout標準輸出,系統預設值是1,所以">/dev/null"等同於"1>/dev/null"2 表示stderr標準錯誤& 表示等同於的意思,2>&1,表示2的輸出重新導向等同於12>&1表示所有的標準輸出和錯誤輸出都將被重新導向到一個叫做out.file 的檔案中3.crontab常用操作列出crontab檔案:crontab -l編輯crontab檔案:crontab -e刪除crontab檔案:crontab -r

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.