linux瀹氭椂浠诲姟鐨勮缃?
涓哄綋鍓嶇敤鎴峰垱寤篶ron鏈嶅姟
1. 閿叆 crontab -e 缂栬緫crontab鏈嶅姟鏂囦欢
渚嬪 鏂囦欢鍐呭濡備笅锛?
*/2 * * * * /bin/sh /home/admin/jiaoben/buy/deleteFile.sh
淇濆瓨鏂囦欢骞跺苟閫€鍑?
*/2 * * * * /bin/sh /home/admin/jiaoben/buy/deleteFile.sh
*/2 * * * * 閫氳繃杩欐瀛楁鍙互璁惧畾浠€涔堟椂鍊欐墽琛岃剼鏈?
/bin/sh /home/admin/jiaoben/buy/deleteFile.sh 杩欎竴瀛楁鍙互璁惧畾浣犺鎵ц鐨勮剼鏈紝杩欓噷瑕佹敞鎰忎竴涓媌in/sh 鏄寚杩愯 鑴氭湰鐨勫懡浠?nbsp; 鍚庨潰涓€娈垫椂鎸囪剼鏈瓨鏀剧殑璺緞
2. 鏌ョ湅璇ョ敤鎴蜂笅鐨刢rontab鏈嶅姟鏄惁鍒涘缓鎴愬姛锛?鐢?crontab -l 鍛戒护
3. 鍚姩crontab鏈嶅姟
涓€鑸惎鍔ㄦ湇鍔$敤 /sbin/service crond start 鑻ユ槸鏍圭敤鎴风殑cron鏈嶅姟鍙互鐢?sudo service crond start锛?杩欓噷杩樻槸瑕佹敞鎰?nbsp; 涓?涓嶅悓鐗堟湰linux绯荤粺鍚姩鐨勬湇鍔$殑鍛戒护涔熶笉鍚?锛屽儚鎴戠殑铏氭嫙鏈洪噷鍙渶鐢?sudo service cron restart 鍗冲彲锛岃嫢鏄湪鏍圭敤涓嬬洿鎺ラ敭鍏ervice cron start灏辫兘鍚姩鏈嶅姟
4. 鏌ョ湅鏈嶅姟鏄惁宸茬粡杩愯鐢?ps -ax | grep cron
5. crontab鍛戒护
cron鏈嶅姟鎻愪緵crontab鍛戒护鏉ヨ瀹歝ron鏈嶅姟鐨勶紝浠ヤ笅鏄繖涓懡浠ょ殑涓€浜涘弬鏁颁笌璇存槑:
crontab -u //璁惧畾鏌愪釜鐢ㄦ埛鐨刢ron鏈嶅姟锛屼竴鑸瑀oot鐢ㄦ埛鍦ㄦ墽琛岃繖涓懡浠ょ殑鏃跺€欓渶瑕佹鍙傛暟
銆€銆€crontab -l //鍒楀嚭鏌愪釜鐢ㄦ埛cron鏈嶅姟鐨勮缁嗗唴瀹?
銆€銆€crontab -r //鍒犻櫎娌′釜鐢ㄦ埛鐨刢ron鏈嶅姟
銆€銆€crontab -e //缂栬緫鏌愪釜鐢ㄦ埛鐨刢ron鏈嶅姟
銆€銆€姣斿璇磖oot鏌ョ湅鑷繁鐨刢ron璁剧疆:crontab -u root -l
銆€銆€鍐嶄緥濡傦紝root鎯冲垹闄red鐨刢ron璁剧疆:crontab -u fred -r
銆€銆€鍦ㄧ紪杈慶ron鏈嶅姟鏃讹紝缂栬緫鐨勫唴瀹规湁涓€浜涙牸寮忓拰绾﹀畾锛岃緭鍏?crontab -u root -e
銆€銆€杩涘叆vi缂栬緫妯″紡锛岀紪杈戠殑鍐呭涓€瀹氳绗﹀悎涓嬮潰鐨勬牸寮?*/1 * * * * ls >> /tmp/ls.txt
浠诲姟璋冨害鐨刢rond甯搁┗鍛戒护
crond 鏄痩inux鐢ㄦ潵瀹氭湡鎵ц绋嬪簭鐨勫懡浠ゃ€傚綋瀹夎瀹屾垚鎿嶄綔绯荤粺涔嬪悗锛岄粯璁や究浼氬惎鍔ㄦ
浠诲姟璋冨害鍛戒护銆俢rond鍛戒护姣忓垎閿轰細瀹氭湡妫€鏌ユ槸鍚︽湁瑕佹墽琛岀殑宸ヤ綔锛屽鏋滄湁瑕佹墽琛岀殑宸?
浣滀究浼氳嚜鍔ㄦ墽琛岃宸ヤ綔銆?
6. crontab鍛戒护閫夐」:
-u鎸囧畾涓€涓敤鎴?
-l鍒楀嚭鏌愪釜鐢ㄦ埛鐨勪换鍔¤鍒?
-r鍒犻櫎鏌愪釜鐢ㄦ埛鐨勪换鍔?
-e缂栬緫鏌愪釜鐢ㄦ埛鐨勪换鍔?
7. cron鏂囦欢璇硶:
鍒?nbsp; 灏忔椂 鏃?nbsp; 鏈?nbsp; 鏄熸湡 鍛戒护
0-59 0-23 1-31 1-12 0-6 command (鍙栧€艰寖鍥?0琛ㄧず鍛ㄦ棩涓€鑸竴琛屽搴斾竴涓换鍔?
璁颁綇鍑犱釜鐗规畩绗﹀彿鐨勫惈涔?
鈥?鈥濅唬琛ㄥ彇鍊艰寖鍥村唴鐨勬暟瀛?
鈥?鈥濅唬琛ㄢ€濇瘡鈥?
鈥?鈥濅唬琛ㄤ粠鏌愪釜鏁板瓧鍒版煇涓暟瀛?
鈥?鈥濆垎寮€鍑犱釜绂绘暎鐨勬暟瀛?
8. 浠诲姟璋冨害璁剧疆鏂囦欢鐨勫啓娉?
鍙敤crontab -e鍛戒护鏉ョ紪杈?缂栬緫鐨勬槸/var/spool/cron涓嬪搴旂敤鎴风殑cron鏂囦欢,涔熷彲浠ョ洿鎺ヤ慨鏀?etc/crontab鏂囦欢
鍏蜂綋鏍煎紡濡備笅锛?
Minute Hour Day Month Dayofweek command
鍒嗛挓 灏忔椂 澶?nbsp; 鏈?nbsp; 澶╂瘡鏄熸湡 鍛戒护
姣忎釜瀛楁浠h〃鐨勫惈涔夊涓嬶細
Minute 姣忎釜灏忔椂鐨勭鍑犲垎閽熸墽琛岃浠诲姟
Hour 姣忓ぉ鐨勭鍑犱釜灏忔椂鎵ц璇ヤ换鍔?
Day