Centos7.3 Startup automatically starts or executes the specified command operation

  • 2021-08-31 09:53:51
  • OfStack

In centos7, the/etc/rc. d/rc. local file has been reduced in permissions and has no execute permissions, so you need to add executable permissions to it.

chmod +x /etc/rc.d/rc.local

Then you can add the command that you want to boot and start yourself in it

vi /etc/rc.d/rc.local

Additional knowledge: centOS 7.2 sets the custom script to service and boots it up

When the jar package of spring boot is deployed online, you want to set it to service and start it up. The steps are as follows:

1. Prepare the script (there are many on the Internet, so don't write it here)

2. Establish a soft connection to the/etc/rc. d/init. d directory

ln -s /springboot/biz /etc/rc.d/init.d

Source File (Absolute Path) Destination Path (Absolute Path)

3. Increase execution authority:

chmod +x biz

4. When executing service abc start, if an error is reported:

line 4: exec: java: not found

Then check the script and add the full path of java as follows:

exec /usr/java/jdk1.8.0_20/jre/bin/java -Xms128m -Xmx1024m -jar

5. Execute service biz start again and start successfully

6. Set the startup and modify the script, which needs to be added in line 2:

# chkconfig: 2345 99 99

7. Add startup:

chkconfig --add biz

chkconfig biz on


Related articles: