八週一次課(9月18日)
10.23 linux任務計劃cron
10.24 chkconfig工具
10.25 systemd管理服務
10.26 unit介紹
10.27 target介紹
10.23 linux任務計劃cron
配置文件位置/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
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
可以指定特定級別的服務關閉或者開啓
自定義啓動服務
第一步在/etc/init.d/ 下面建立自己的服務腳本
第二部 chkconfig --add 123
chkconfig --list
就可以實現開機自啓服務
10.25 systemd管理服務
cent7的服務管理工具
列出所有的服務。
systemctl enable 開機啓動。
systemctl is-enabled XX查看某個服務是否開機自啓
enable就會創建一個軟連接。
10.26 unit介紹
systemctl list-units --all列出所有的units
10.27 target介紹
[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'
開機就是命令行模式之前是圖形界面模式。