cron創建定時任務

本文介紹 cron創建定時任務

cron創建定時任務

This article was original written by XRBLS, welcome re-post, first come with https://jinfagang.github.io . but please keep this copyright info, thanks, any question could be asked via wechat: jintianiloveu

cron是linux自帶的一個定時任務管理器,通過cron創建定時任務需要如下步驟:

  1. 首先得把cron的log打開,不然你看不到log

    sudo vim /etc/rsyslog.d/50-default.conf
    

    把cron.*那一行註釋去掉。

    然後重啓rsys:

    sudo services rsyslog restart
    
  2. 編寫你的腳本sh,並將它放到一個目錄下:

    # 比如 /root/crontabs/cron_run_lidar.sh
    
    crontab -e
    
    編輯加入:
    
    10 22 * * * (/bin/sh /root/crontabs/cron_run_lidar.sh)
    表示,每天的22:10,執行那個sh腳本文件。
    

接着就可以了。查看任務用 crontab -l.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章