The script is written so that you don’t need to manually start various services (also to be lazy, haha)
1. Enter terminal input
Create a script file with the suffix .sh
touch test.sh
Edit script
vim test.sh
test.sh write script content
2. Write test.sh script
#! /bin/bash
### BEGIN INIT INFO
# Provides: test
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start:2345
# Default-Stop:016
# Short-Description: start test
# Description: start test
### END INIT INFO
# Script content written here
cd /home/Desktop/./test.sh
exit 0
Start with #!/bin/bash and write the script content in the middle and end with exit0
3. Move the test.sh file to the /etc/init.d directory
Move files
sudo mv test.sh /etc/init.d/
Add permissions to files
chmod +750 test.sh
Set automatic startup
sudo update-rc.d test.sh defaults
to sum up
The above is a shell script written in ubuntu that the editor introduced to you to start automatically. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!
Recommended Posts