淺談:linux cron 計劃任務常用符號小結
[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 工作內容
-l (list user's crontab) 查看crontab工作內容
-r (delete user's crontab) 刪除所有的crontab任務
-i (prompt before deleting user's crontab)
-s (selinux context)
默認情況下,任何用戶只要不被列入/etc/cron.deny 當中,都可以執(zhí)行”crontab –e” 去編輯自己的例行性命令了,
周的數(shù)字為0-7時,都代表”星期天”的意思,
輔助字符
系統(tǒng)任務計劃
[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是針對用戶的cron來設計的。
基本上cron這個服務的最低檢測限制是”分鐘”,所以cron每分鐘去讀取一次/etc/crontab 與/var/spool/cron 里面的數(shù)據(jù)內容。
標準輸出(stout): 代碼為1 使用>或>>
標準錯誤輸出(stderr): 代碼為2 使用2> 或2>>
黑洞/dev/null
錯誤輸出 2>&1
cron 讓計劃任務不在屏幕上輸出采用 > /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客戶端安裝
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
相關文章
linux 驅動之Kconfig文件和Makefile文件實例
這篇文章主要介紹了linux 驅動之Kconfig文件和Makefile文件實例的相關資料,需要的朋友可以參考下2017-01-01
linux執(zhí)行sh腳本報錯:$’\r’: 未找到命令的完美解決方法
本文給大家介紹linux執(zhí)行sh腳本報錯:$’\r’: 未找到命令的完美解決方法,原因分析及解決辦法給大家講解的非常明白,感興趣的朋友跟隨小編一起看看吧2023-02-02
jenkins 實現(xiàn)shell腳本化定時執(zhí)行任務的方法
這篇文章主要介紹了jenkins 實現(xiàn)shell腳本化定時執(zhí)行任務,解決訪問是jenkins構建好之后將jar遠程推送到生產服務器,提前退出后臺執(zhí)行服務器遠程腳本,腳本通過ngnx提前切走nginx代理auction sleep 1800s,半小時后執(zhí)行更新重啟,具體操作過程跟隨小編一起看看吧2022-01-01
hive-shell批量命令執(zhí)行腳本的實現(xiàn)方法
今天小編就為大家分享一篇hive-shell批量命令執(zhí)行腳本的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-06-06

