systemctl list-units --type=service #查看所有已啟動的服務
systemctl enable httpd.service #加入開機自啟動服務
systemctl enable rsyncd.service #同步數據的服務
2、開機后執行自定義腳本
1)編輯自啟動腳本的文件
vim /yourpath/serverstart_all.sh #!/bin/bash sh /yourserverpath/server_start.sh
2)將腳本標記為可執行文件
chmod +x /yourpath/serverstart_all.sh
3)將/etc/rc.d/rc.local文標記為可執行文件
chmod +x /etc/rc.d/rc.local
4)編輯/etc/rc.d/rc.local文件,增加 自啟動腳本的執行
vim /etc/rc.d/rc.local /yourpath/serverstart_all.sh
這里做了個啟動后的測試,在serverpath的log下輸出結果文件,重啟后輸出正常
filename="/yourserverpath/log/`date +%y%m%d_%H%M%S_`"
sh /yourserverpath/server_start.sh>$filename"servername.log"
3、開機后制動檢測並啟動特定進程
ps aux|grep yourprocessname