ubuntu in writing shell scripts at startup

Instead of manually writing scripts in order to open a variety of services (also for lazy haha)

1. Go to the input terminal

Create a suffix .sh script file
touch test.sh
edit the script
vim test.sh

test.sh scripted content

 2. Write a script test.sh

 

 1 #!/bin/bash
 2 
 3 ### BEGIN INIT INFO
 4 # Provides:          test
 5 # Required-Start:    $remote_fs $syslog
 6 # Required-Stop:     $remote_fs $syslog
 7 # Default-Start:     2 3 4 5
 8 # Default-Stop:      0 1 6
 9 # Short-Description: start test
10 # Description:       start test
11 ### END INIT INFO
12 
13 #此处编写脚本内容
14 cd /home/Desktop/
15 ./test.sh
16 exit 0

With #! Intermediate / bin / bash at the beginning of the end of the script written content exit0 

3. Move the file to the /etc/init.d directory test.sh

Moving Files

sudo mv test.sh /etc/init.d/

Added to the file permissions

chmod +750 test.sh

Set at startup

sudo update-rc.d test.sh defaults

 4. Such a startup script to automate the completion strategy

Guess you like

Origin www.cnblogs.com/huisir/p/11976684.html