Article directory
Why can't I find the PID file when starting Redis ? Where is the Redis PID file?

LinuxHow to check the location address of the Redis process pid file?
Linux find redis process command▼
ps -ef | grep redisReturn to display the following query results▼
redis 28221 1 1 Feb08 ? 00:13:19 /usr/bin/redis-server 127.0.0.1:6379
- Looking at the redis process, I can't find the location of the pid file. What should I do?
redis.pid file not found?
The Redis startup script is supposed to create a pid file on startup, but we've confirmed all the settings we can find, and no pid file is created.
What if the Redis daemon didn't create the PID file?
How is redis.pid generated?
For CentOS 7 Linux servers :
The name of the Redis server isredis.service, SSH Enter the following command to start editing▼
systemctl edit redis.serviceadd this ▼
[Service] ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid" PIDFile=/var/run/redis/redis.pid
Restart the service:
systemctl daemon-reload systemctl restart redis monit reload
Then, the file address of this location will be used to generate the pid file of Redis:/etc/systemd/system/redis.service.d/override.conf
pid file address▼
cat /var/run/redis/redis.pid
=> 27585What's in the redis.pid file?
- The redis.pid file stores the ID of the process.
- in Use
catCommand to view, you can see that there is only one line, recording the ID of the process.
What is the role of the redis.pid file?
- The role of the redis.pid file is to prevent multiple copies of the process from being started.
- The Monit program monitors the redis process and needs to use the location address of the redis.pid file.
What is the principle of pid file?
- After the process is running, a file lock is added to the .pid file.
- Only the process that obtains the lock has write permission (F_WRLCK), and writes its own pid to the file.
- Other processes trying to acquire the lock will automatically exit.
Monit monitoringAdd Redis pid file location address
Configuration files for monitoring programs in Monitmonit.confIn, add the location address of the pid file of Redis ▼
check process redis with pidfile "/var/run/redis/redis.pid" start program "/usr/bin/systemctl start" stop program "/usr/bin/systemctl stop" if failed host 127.0.0.1 port 6379 then restart if 5 restarts within 5 cycles then timeout group redis
How do I configure the monit.conf file?
Monit monitoring is a free and open-source software . Click the link below to view the tutorial on installing Monit monitoring software in CWP7 ▼
Hopefully, the article "Can't find Redis PID? How to configure the PID file location after Redis starts," shared on Chen Weiliang's blog ( https://www.chenweiliang.com/ ), will be helpful to you.
Feel free to share this article's link: https://www.chenweiliang.com/cwl-26494.html

