Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to automatically execute scripts when Linux boots up

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report