SYSTEMD

八週一次課(9月18日)

10.23 linux任務計劃cron

10.24 chkconfig工具

10.25 systemd管理服務

10.26 unit介紹

10.27 target介紹


10.23 linux任務計劃cron

wKiom1m_2DrxuzTvAAN9YU5XpZk079.png

配置文件位置/etc/crontab

 * * * * *  /bin/bash /tmp/1 > > /tmp/1 2>>/tmp/2 每分鐘執行

0 3 1-10 */2 *  沒兩個月的1-10號的三點執行。

 systemctl start crond  啓動服務。

注意:在寫腳本的時候需要加上絕對路徑。

[root@111 ~]# cat /var/spool/cron/root 

 * * * * *  echo "123" >/tmp/1

 計劃任務存儲的地方


10.24 chkconfig工具

cent7用systemd

wKiom1m_2EzTKDFGAARWuanS8DE491.png

chkconfig管理的腳本的路徑

chkconfig network off 關閉服務

系統分了七個級別 每個級別只有特定的服務是開啓的。

chkconfig --list查看

[root@111 ~]# chkconfig --list


Note: This output shows SysV services only and does not include native

      systemd services. SysV configuration data might be overridden by native

      systemd configuration.


      If you want to list systemd services use 'systemctl list-unit-files'.

      To see services enabled on particular target use

      'systemctl list-dependencies [target]'.


iprdump         0:off 1:off 2:on 3:on 4:on 5:on 6:off

iprinit         0:off 1:off 2:on 3:on 4:on 5:on 6:off

iprupdate       0:off 1:off 2:on 3:on 4:on 5:on 6:off

netconsole     0:off 1:off 2:off 3:off 4:off 5:off 6:off

wKiom1m_2FnAN_2OAABJKS9xlik052.png

可以指定特定級別的服務關閉或者開啓

自定義啓動服務

第一步在/etc/init.d/ 下面建立自己的服務腳本

第二部 chkconfig --add 123

chkconfig --list

就可以實現開機自啓服務

10.25 systemd管理服務

cent7的服務管理工具

wKiom1m_2G_wllxXAAXUdgx_UmM993.png

wKiom1m_2HnBAft2AARO2dONpKU687.png

列出所有的服務。

 systemctl enable  開機啓動。

 systemctl is-enabled  XX查看某個服務是否開機自啓

enable就會創建一個軟連接。

10.26 unit介紹

wKioL1m_2FnSoHGNAAAVlsHyggQ970.png

wKiom1m_2Jvyux9eAAg4LMrdb2k535.png

wKioL1m_2GvC9uwwAAAp_HzytSM009.png

systemctl list-units --all列出所有的units

10.27 target介紹

wKiom1m_2NPC4eRHAASdIIvv0cU320.png

[root@111 system]# systemctl get-default 

graphical.target 查看默認的target 

[root@111 system]# systemctl set-default multi-user.target 

rm '/etc/systemd/system/default.target'

ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'

開機就是命令行模式之前是圖形界面模式。




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