Home > Database > Redis > How to set redis to enable auto-start on Linux

How to set redis to enable auto-start on Linux

王林
Release: 2023-06-02 17:58:09
forward
3971 people have browsed it

Redis starts automatically on boot in centos7
Create the redis.service file in the system service directory
vi /etc/systemd/system/redis.service

Write the following content:
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf (Fill in the path to your redis configuration file here)
PrivateTmp=true
[Install]
WantedBy=multi-user.target

Test and add auto-start on boot
Close redis-server first
systemctl stop redis.service
Open redis-server
Systemctl start redis.service #If the service is on, using this command will Startup failed.
Successfully opened, add the service to start automatically at boot
Systemctl enable redis.service #Note that it cannot be followed by a space
Reboot #Restart
Check the service running status: systemctl status redis.service

All commands
Systemctl start redis.service #Start redis service
Systemctl enable redis.service #Set auto-start at boot
Systemctl disable redis.service #Stop auto-start at boot
systemctl status redis.service # View the current status of the service
Systemctl restart redis.service #Restart the service
Systemctl list-units –type=service #View all started services

Note: The above method is not only applicable to redis , also suitable for other service deployment

The above is the detailed content of How to set redis to enable auto-start on Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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