淺談:linux cron 計(jì)劃任務(wù)常用符號(hào)小結(jié)
[root@wx-a ~]# crontab --help
crontab: invalid option -- '-'
crontab: usage error: unrecognized option
usage: crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e (edit user's crontab) 編輯crontab 工作內(nèi)容
-l (list user's crontab) 查看crontab工作內(nèi)容
-r (delete user's crontab) 刪除所有的crontab任務(wù)
-i (prompt before deleting user's crontab)
-s (selinux context)
默認(rèn)情況下,任何用戶(hù)只要不被列入/etc/cron.deny 當(dāng)中,都可以執(zhí)行”crontab –e” 去編輯自己的例行性命令了,
周的數(shù)字為0-7時(shí),都代表”星期天”的意思,
輔助字符
系統(tǒng)任務(wù)計(jì)劃
[root@wx-a ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
crontab -e是針對(duì)用戶(hù)的cron來(lái)設(shè)計(jì)的。
基本上cron這個(gè)服務(wù)的最低檢測(cè)限制是”分鐘”,所以cron每分鐘去讀取一次/etc/crontab 與/var/spool/cron 里面的數(shù)據(jù)內(nèi)容。
標(biāo)準(zhǔn)輸出(stout): 代碼為1 使用>或>>
標(biāo)準(zhǔn)錯(cuò)誤輸出(stderr): 代碼為2 使用2> 或2>>
黑洞/dev/null
錯(cuò)誤輸出 2>&1
cron 讓計(jì)劃任務(wù)不在屏幕上輸出采用 > /dev/null 2>&1
[root@wx-a ~]# crontab -l
*/1 * * * * echo "hello" >> /tmp/test.txt
[root@wx-a ~]# cat /tmp/test.txt
hello
[root@wx-a ~]# cat /tmp/test.txt
hello
hello
讓輸出到黑洞里面去
[root@wx-a ~]# crontab -l
*/1 * * * * echo "hello"
[root@wx-a ~]# crontab -l
*/1 * * * * echo "hello" >/dev/null 2>&1 輸出到黑洞了
其他的幫助可以查看 man cron 或者man crontab
ps:ocsng linux客戶(hù)端安裝
aptitude -y install gcc automake autoconf libtool make
aptitude -y install dmidecode libxml-simple-perl libcompress-zlib-perl libnet-ip-perl libwww-perl libdigest-md5-perl libnet-ssleay-perl
aptitude -y install libcrypt-ssleay-perl libnet-snmp-perl libproc-pid-file-perl libproc-daemon-perl net-tools libsys-syslog-perl pciutils smartmontools read-edid nmap
tar –xvzf Ocsinventory-Agent-2.0.x.tar.gz
cd Ocsinventory-Agent-2.0.x
env PERL_AUTOINSTALL=1 perl Makefile.PL
make
make install
相關(guān)文章
Shell執(zhí)行/調(diào)用Java/Jar程序例子的實(shí)例詳解
這篇文章主要介紹了Shell執(zhí)行/調(diào)用Java/Jar程序例子的實(shí)例詳解的相關(guān)資料,這里提供實(shí)例幫助大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-08-08寫(xiě)出健壯Bash Shell腳本的一些技巧總結(jié)
這篇文章主要介紹了寫(xiě)出健壯Bash Shell腳本的一些技巧總結(jié),本文總結(jié)了set -u、set -e、竟態(tài)條件、信號(hào)描述等內(nèi)容,需要的朋友可以參考下2014-10-10利用expect命令實(shí)現(xiàn)Shell自動(dòng)化交互的方法詳解
我們通過(guò)Shell可以實(shí)現(xiàn)簡(jiǎn)單的控制流功能,如:循環(huán)、判斷等。下面這篇文章主要給大家介紹了關(guān)于利用expect命令實(shí)現(xiàn)Shell自動(dòng)化交互的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來(lái)一起看看吧。2017-12-12Shell腳本中$符號(hào)的嵌套使用方法小結(jié)
在編寫(xiě)Shell腳本時(shí),通過(guò)嵌套使用$符號(hào),間接獲取變量或表達(dá)式的值的具體方法,文中根據(jù)實(shí)例編碼詳細(xì)介紹的十分詳盡,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2023-05-05Linux基礎(chǔ)命令last 命令實(shí)例詳解
Linux last命令用于顯示系統(tǒng)開(kāi)機(jī)以來(lái)獲是從每月初登入者的訊息。本文主要給大家介紹Linux基礎(chǔ)命令last 命令實(shí)例詳解,感興趣的朋友跟隨小編一起看看吧2018-10-10Linux在shell中自動(dòng)生成1到100的數(shù)組方法(兩種方法)
之前自己在寫(xiě)shell腳本的時(shí)候,需要自動(dòng)創(chuàng)建1-100的文本確不知道該如何去創(chuàng)建。今天小編給大家分享兩種方法,需要的朋友參考下2017-02-02