Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to configure the Boot self-boot execution script for Linux

Shulou Source: shulou.com Published: 2022-06-01 05:03:31 10月03日 Update

This article mainly introduces how to configure Linux boot execution script, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Script qidong.sh [root@c69-01 scripts] # vim / server/scripts/qidong.sh [root@c69-01 scripts] # cat / server/scripts/qidong.sh #! / bin/bash / bin/echo $(/ bin/date +% Flying% T) > > / tmp/qidong.log method 1: modify / etc/rc.local

/ etc/rc.local, which is a linked file

[root@c69-01 ~] # ll / etc/rc.local lrwxrwxrwx. 1 root root 13 Feb 5 10:03 / etc/rc.local-> rc.d/rc.local

Modify / etc/rc.local file

[root@c69-01 scripts] # tail-n 1 / etc/rc.local / bin/bash / server/scripts/qidong.sh > / dev/null 2 > / dev/null

Restart the system to view the results

[root@c69-01 ~] # cat / tmp/qidong.log 2018-02-1919 1911 1911 1911 / 1911 # cat / tmp/qidong.log 2018-02-1931 1911 1911 1911 19

The script has been booted and started automatically

Method 2: chkconfig management

Delete the configuration of method 1

[root@c69-01 ~] # vim / etc/init.d/test #! / bin/bash # chkconfig: 3 88 88 / bin/bash / server/scripts/qidong.sh > / dev/null 2 > / dev/null [root@c69-01 ~] # chmod + x / etc/init.d/test

Add to chkconfig, boot automatically

[root@c69-01] # chkconfig-- add test [root@c69-01] # chkconfig-- list test test 0:off 1:off 2:off 3:on 4:off 5:off 6:off

Restart the system to view the results

[root@c69-01 ~] # cat / tmp/qidong.log 2018-02-1919 1951-02-1911 2315 1951-02-1931 1951-02-1911 1315 5915 10

The operation is successful

Turn it off and start.

[root@c69-01 ~] # chkconfig test off [root@c69-01 ~] # chkconfig-- list test test 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Remove test from chkconfig Management

[root@c69-01 ~] # chkconfig-- list test test 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@c69-01 ~] # chkconfig-- del test [root@c69-01 ~] # chkconfig-list test service test supports chkconfig, but is not referenced in any runlevel (run 'chkconfig-- add test') Thank you for reading this article carefully I hope the article "how to configure the boot execution script for Linux" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Scripts articles configurations files methods systems results management success value interests at the same time more friends knowledge editing industry information information channels links Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi vpn Shulou Technology Docker macOS