Linux Ubuntu 18.04 開機自動執行指令
#切至root權限
sudo su
nano lib/systemd/system/rc.local.service
文件後面加上下列
[Install]
WantedBy=multi-user.target
Alias=rc.local.service
存檔
建立 rc.local 檔
cd /etc
sudo touch rc.local
nano rc.local
文件內容如下
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
mount –bind /home/web_backup/ /var/www/html/web/
exit 0
文件說明:這邊我主要是要每次啟動自動mount web_backup 到 web資料夾中
#rc.local 變更執行權限
sudo chmod +x /etc/rc.local
#啟用服務
sudo systemctl enable rc-local.service
重開機如果有自動mount就是成功囉!
sudo su
nano lib/systemd/system/rc.local.service
文件後面加上下列
[Install]
WantedBy=multi-user.target
Alias=rc.local.service
存檔
建立 rc.local 檔
cd /etc
sudo touch rc.local
nano rc.local
文件內容如下
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
mount –bind /home/web_backup/ /var/www/html/web/
exit 0
文件說明:這邊我主要是要每次啟動自動mount web_backup 到 web資料夾中
#rc.local 變更執行權限
sudo chmod +x /etc/rc.local
#啟用服務
sudo systemctl enable rc-local.service
重開機如果有自動mount就是成功囉!
留言
張貼留言