八周一次課(9月18日)
10.23 linux任務計劃cron
10.24 chkconfig工具
10.25 systemd管理服務
10.26 unit介紹
10.27 target介紹
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL5cDMrpFcYVTVZljTBFkdUpXd4JHRy8Vbx02bpt0dvwlMF9CX2AzLcBDMN9CXyAzcml3dvwVbvNmLvR3YxUjLzM3Lc9CX6MHc0RHaiojIsJye.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
計劃任務存儲的地方
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
就可以實作開機自啟服務
cent7的服務管理工具
列出所有的服務。
systemctl enable 開機啟動。
systemctl is-enabled XX檢視某個服務是否開機自啟
enable就會建立一個軟連接配接。
systemctl list-units --all列出所有的units
[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'
開機就是指令行模式之前是圖形界面模式。