生活随笔
收集整理的這篇文章主要介紹了
crontab、chkconfig、systemd、unit、targ
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
10.23 linux任務(wù)計(jì)劃cron
# cat /etc/crontab liunx下的任務(wù)計(jì)劃配置文件crontab -u、-e、-l、-r格式:分 時(shí) 日 月 周 user command分范圍0-59,時(shí)范圍0-23,日范文:1-31,月范圍:1-12,星期分為:0-6(sunday=0 or 7)# crontab -e進(jìn)入到任務(wù)計(jì)劃編輯界面0 3 * * * /bin/bash /usr/local/sbin/123.sh >>/tmp/123.log 2>>/tmp/123.log //每個(gè)星期,每個(gè)月的每天的3點(diǎn)執(zhí)行命令0 3 1-10 */2 2,5 /bin/bash /usr/local/sbin/123.sh >>/tmp/123.log 2>>/tmp/123.log //每周二周五,雙數(shù)月份的前10天的3點(diǎn),執(zhí)行任務(wù)# sytemctl start crond 啟動(dòng)服務(wù)# systemctl stop crond //關(guān)閉服務(wù)# ps aux | grep cron 查看是否有此進(jìn)程# systemctl status crond查看狀態(tài),Actice綠色啟動(dòng)該計(jì)劃在/var/spool/cron/root(最后是以用戶名命名的文件)# cront -l //列出信息# cront -e //編輯# cront -r //刪除# cront -u root -l //查看指定用戶的計(jì)劃10.24 Linux系統(tǒng)服務(wù)管理-chkconfig工具
# chkconfig --list //當(dāng)前系統(tǒng)中所有服務(wù) # ls /etc/init.d/# chkconfig network off# chkconfig --level 3 network off //指定某個(gè)級(jí)別的服務(wù)關(guān)閉# chkconfig --level 345 network off //指定多個(gè)級(jí)別的某個(gè)服務(wù)關(guān)閉# chkconfig --del network# chkconfig --add network將腳本放到/etc/init.d/下再將服務(wù)add就可以將腳本在某幾個(gè)級(jí)別運(yùn)行的時(shí)候執(zhí)行了10.25 systemd管理服務(wù)
# systemctl list-units --all--type=service幾個(gè)常用的服務(wù)相關(guān)的命令 #systemctl enable crond.service //讓服務(wù)開(kāi)機(jī)啟動(dòng)# systemctl disable crond //讓服務(wù)開(kāi)機(jī)不啟動(dòng)# systemctl status crod //查看狀態(tài)# systemctl stop crond //停止服務(wù)# systemctl start crond //啟動(dòng)服務(wù)# systemctl restart crond //重啟服務(wù)# systemctl is-enabled crond //檢查服務(wù)是否開(kāi)機(jī)啟動(dòng)10.26 unit介紹
ls /usr/lib/systemd/system //系統(tǒng)所有unit,分為以下類型:service 系統(tǒng)服務(wù)target 多個(gè)unit組成的組device 硬件設(shè)備mount 文件系統(tǒng)掛載點(diǎn)automount 自動(dòng)掛載點(diǎn)path 文件或路徑scope 不是有systemd啟動(dòng)的外部進(jìn)程slice進(jìn)程組snapshot systemd快照socket 進(jìn)程間通信套接字swap swap文件timer 定時(shí)器10.27 target介紹
系統(tǒng)爲(wèi)了方便管理用target來(lái)管理unitsystemctl list-unit-files --type=targetsystemctl list-dependencies multi-user.target //查看指定target下面有哪些unitsystemctl get-default //查看系統(tǒng)默認(rèn)的targetsystemctl set-default multi-user.target一個(gè)service屬于一種類型的unit多個(gè)unit組成了一個(gè)target一個(gè)target里面包含了多個(gè)servicecat /usr/lib/systemd/system/sshd/service // 看【install】部分擴(kuò)展
anacron http://blog.csdn.net/strikers1982/article/details/4787226xinetd服(默認(rèn)機(jī)器沒(méi)有安裝這個(gè)服務(wù),需要yum install xinetd安裝) http://blog.sina.com.cn/s/blog_465bbe6b010000vi.htmlsystemd自定義啟動(dòng)腳本http://www.jb51.net/article/100457.htm
轉(zhuǎn)載于:https://my.oschina.net/u/3803446/blog/1811690
總結(jié)
以上是生活随笔為你收集整理的crontab、chkconfig、systemd、unit、targ的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。