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

不言
Release: 2019-03-25 16:04:42
Original
3404 people have browsed it

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
Copy after login

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

# rc-service local start
Copy after login

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
Copy after login
#!/bin/sh
# Show below message on system startup
echo "Welcome back!"
Copy after login

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
Copy after login
#!/bin/sh
# Show below message on system shutdown
echo "Good bye!
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template