How to start Redis in background?

redis-background

Redis is an opensource in-memory key-value store . It supports data structures such as strings, hashes, lists, sets, sorted sets and many more. In default configuration Redis works in foreground.That means if you start redis it will run on foreground and prints the logs on console. This article explain how to start redis in background.

How to run Redis in background or as a daemon?

You need to open Redis configuration file “redis.conf” which is located at the root of the redis distribution, set configuration option “daemonize” to “yes” , as follows

1 2 3 4 5   # By default Redis does not run as a daemon. Use ‘yes’ if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize yes  

After making these changes, restart redis with following

1 2 3   ./redisserver ../redis.conf  

Redis will start running on background as a daemon. You can verify Redis is running by using the linux commands

1 2 3 4 5 6 7 8   [root@test.test.com ~]# ps aux |grep redis root 31071 0.1 0.0 139340 1976 ? Ssl 14:15 0:00 redisserver 127.0.0.1:6379 [root@test.test.com ~]# [root@test.test.com ~]# netstat -nap |grep 6379 tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 31071/redisserver [root@test.test.com ~]#  

From the outputs we can see that redis is running and listening on tcp port 6379

Feel free to contact us if you face any issue . Always happy to help ????

Author: , 0000-00-00