Ubuntu 14.04 sets the method to boot the script
- 2020-05-15 03:19:30
- OfStack
rc local script
The rc.local script is a script that is automatically executed when the ubuntu is booted, and we can add command line instructions to this script. The script is under the /etc/ path and requires the root permission to be modified.
The script format is as follows:
#!/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.
exit 0
Note: 1 must add the command before exit 0
How do I add a boot script to ubuntu
1. Create a new script file new_service.sh
#!/bin/bash
# command content
exit 0
2. Set permissions
sudo chmod 755 new_service.sh
3. Place the script in the startup directory
sudo mv new_service.sh /etc/init.d/
4. Add the script to the startup script
Execute the following instruction, where 90 indicates 1 priority. The higher the value, the later the execution
cd /etc/init.d/
sudo update-rc.d new_service.sh defaults 90
Remove the Ubuntu boot script
sudo update-rc.d -f new_service.sh remove
conclusion
The above is the entire content of this article, I hope the content of this article can bring 1 definite help to everyone's study or work, if you have any questions, you can leave a message to communicate.