Get the App
SLTechnology News&Howtos  ›  Development  › 

How to automatically execute scripts when Linux boots up

Shulou Source: shulou.com Published: 2022-06-01 15:36:23 10月02日 Update

Most people do not understand the knowledge of this article "how to automatically execute the script on Linux boot", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Linux boot how to automatically execute the script" article.

Boot the script qidong.sh to be started

❝

[root@c69-01 scripts] # vim / server/scripts/qidong.sh [root@c69-01 scripts] # cat / servermax scriptsUniverse qidong.shrunken binbinBash Bash Binder 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.locallrwxrwxrwx. 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.log2018-02-1934 23 30 purl 56

The script has been booted and started automatically

Method 2: chkconfig management

Delete the configuration of method 1

❝

[root@c69-01 ~] # vim / EtcUnip init.dUnip Testample Bash # chkconfig: 388 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 testtest 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.log2018-02-1919 1951-02-1919-2315 1915-02-1919-2315 5915 10

The operation is successful

Turn it off and start.

❝

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

Remove test from chkconfig Management

❝

[root@c69-01 ~] # chkconfig-- list testtest 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 testservice test supports chkconfig, but is not referenced in any runlevel (run 'chkconfig-- add test') these are the contents of this article on "how to automatically execute scripts when Linux boots up". I believe you all have some understanding. I hope the content shared by the editor will be helpful to all of you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Scripts content documents methods articles knowledge articles systems results management success value most that is more steps knowledge points industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MariaDB Shulou Technology macOS Redmi