Starting, Stopping, Restarting, and Checking the Status of Redis Server
Describes how to start, stop, restart, and check the status of the Redis server.
Checking the status of Redis
To check the status of Redis, use the systemctl command "status".sudo systemctl status redis
If it is running
If the system is running, the following message will be displayed.redis.service redis.service - Redis persistent key-value database Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/redis.service.d mqlimit.conf Active: active (running) since Wed 2020-07-29 09:19:06 JST; 16min ago Main PID: 27074 (redis-server) CGroup: /system.slice/redis.service mq27074 /usr/bin/redis-server 127.0.0.1:6379
If it is stopped
If the service is stopped, the following message will be displayed.
redis.service - Redis persistent key-value database Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/redis.service.d mqlimit.conf Active: inactive (dead)
Start Redis
To start Redis, use the systemctl command "start", run it with root privileges using the sudo command.
sudo systemctl start redis
Even if the startup is successful, you will not get a message saying it was successful. Please check the status.
Stopping Redis
To stop Redis, use the systemctl command "stop", run as root using the sudo command.sudo systemctl stop redis
If the stop is successful, no message will be returned. Please check the status.
Restart Redis
To restart Redis, use the systemctl command "restart", run it with root privileges using the sudo command.
sudo systemctl restart redis
restart simply executes the stop command, and then executes the start command.
How to view the log of starting and stopping Redis
Servers such as Redis are centrally managed by a program called systemd.
Redis start/stop logs are output to the systemd logs.
To view the systemd logs, use the journalctl command. Note that you cannot see the logs of the Redis server unless you run it with sudo. If you want to see only the last part of the log, use the "-r" option.
sudo journalctl -r -u redis
Here is a sample of the log
Jul 29 09:44:13 t Jul 29 09:44:13 tk2-261-40258.vs.sakura.ne.jp systemd[1]: Started Redis persistent key-value database. Jul 29 09:44:13 tk2-261-40258.vs.sakura.ne.jp systemd[1]: Starting Redis persistent key-value database... Jul 29 09:43:27 tk2-261-40258.vs.sakura.ne.jp systemd[1]: Stopped Redis persistent key-value database... Jul 29 09:43:27 tk2-261-40258.vs.sakura.ne.jp systemd[1]: Stopping Redis persistent key-value database... Jul 29 09:19:06 tk2-261-40258.vs.sakura.ne.jp systemd[1]: Started Redis persistent key-value database... Jul 29 09:19:06 tk2-261-40258.vs.sakura.ne.jp systemd[1]: Starting Redis persistent key-value database...
How to view the systemd configuration file for Redis
You can view the Redis systemd configuration file by using "systemctl status redis".
Let's look at the configuration file using the cat command.
cat /lib/systemd/system/redis.service