Home >Operation and Maintenance >Linux Operation and Maintenance >How to set up startup and shutdown scripts on Gentoo Linux

How to set up startup and shutdown scripts on Gentoo Linux

不言
不言Original
2019-03-25 16:04:423388browse

Sometimes it is necessary to run commands or shell scripts during system startup and shutdown. This helps to start the service when the system starts and stop the service when the system shuts down. This article will introduce about running system startup and shutdown scripts on Gentoo Linux.

How to set up startup and shutdown scripts on Gentoo Linux

Now scripts with the suffix .start in the /etc/local.d/ directory will be executed when the system starts, and all scripts with the suffix .stop will be executed when the system starts. Executed during shutdown. First make sure the local.d script is enabled using the following steps.

Enable local.d scripts

To start a local.d script on boot, add its init.d script to the default runlevel

# rc-update add local default

Now, start the service by performing an OpenRC check on the stopped service in the default runlevel:

# rc-service local start

Run script on startup

Create a script /etc /local.d/myService.start and put your content in it. This will be performed during system boot.

# vi /etc/local.d/myService.start
#!/bin/sh
# Show below message on system startup
echo "Welcome back!"

Run script on shutdown

Create a script /etc/local.d/myservice.stop and put your content in it. This will be performed during system shutdown.

# vi /etc/local.d/myService.stop
#!/bin/sh
# Show below message on system shutdown
echo "Good bye!

This article has ended here. For more exciting content, you can pay attention to the Linux Video Tutorial column of the PHP Chinese website!

The above is the detailed content of How to set up startup and shutdown scripts on Gentoo Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn