日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無(wú)先后,達(dá)者為師

網(wǎng)站首頁(yè) 編程語(yǔ)言 正文

ubuntu開(kāi)機(jī)自啟動(dòng)服務(wù)設(shè)置_Linux

作者:Wogg ? 更新時(shí)間: 2022-03-20 編程語(yǔ)言

在ubuntu 下創(chuàng)建服務(wù)及自啟動(dòng)的方法:

1. 在 [/lib/systemd/system] 創(chuàng)建sandtable.service 服務(wù),

[Unit]
Description=/etc/sandtable Compatibility
Documentation=man:systemd-sandtable-generator(8)
ConditionFileIsExecutable=/etc/sandtable
After=network.target
 
[Service]
Type=forking
ExecStart=/etc/sandtable start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
 
[Install]
WantedBy=multi-user.target  
Alias=sandtable.service

2. 創(chuàng)建啟動(dòng)腳本

在[/etc]文件夾下創(chuàng)建sandtable啟動(dòng)腳本,切記加上[腳本后&], 保證服務(wù)不影響系統(tǒng)啟動(dòng),不然那可能導(dǎo)致系統(tǒng)無(wú)法正常啟動(dòng)后果。

#!/bin/sh
/home/ubuntu/setup >> /home/ubuntu/test.log&

3. 啟動(dòng)服務(wù)

systemctl start sandtable.service #啟動(dòng)服務(wù)
 
systemctl status sandtable.service #查看服務(wù)是否啟動(dòng)
 
systemctl enable sandtable.service #開(kāi)機(jī)運(yùn)行服務(wù)
 
systemctl is-enabled sandtable.service #查詢服務(wù)是否開(kāi)機(jī)啟動(dòng)

4 服務(wù)常用命令

systemctl is-enabled servicename.service #查詢服務(wù)是否開(kāi)機(jī)啟動(dòng)
 
systemctl enable *.service #開(kāi)機(jī)運(yùn)行服務(wù)
 
systemctl disable *.service #取消開(kāi)機(jī)運(yùn)行
 
systemctl start *.service #啟動(dòng)服務(wù)
 
systemctl stop *.service #停止服務(wù)
 
systemctl restart *.service #重啟服務(wù)
 
systemctl reload *.service #重新加載服務(wù)配置文件
 
systemctl status *.service #查詢服務(wù)運(yùn)行狀態(tài)

5.桌面系統(tǒng)的開(kāi)啟與關(guān)閉

// 關(guān)閉桌面系統(tǒng)
sudo systemctl set-default multi-user.target
sudo reboot
 
// 打開(kāi)桌面系統(tǒng)
sudo systemctl set-default graphical.target
sudo reboot

6. 桌面版設(shè)置的wifi 在下邊路徑進(jìn)行修改替換即可

 /etc/NetworkManager/system-connections

原文鏈接:https://blog.csdn.net/qq_31329259/article/details/122174377

欄目分類
最近更新