Does anyone know how to pass the auth to redis "when it is started in systemd." You have to use a custom init script here. Mine is the following:

Description = Redis In-Memory Store 
After = network.target

User = redis 
ExecStart = /www/redis/redis-4.0.11/src/redis-server /www/redis/tests/redis.conf 
ExecStop = /www/redis/redis-4.0.11/src/redis-cli shutdown 
RestartSec = 3s 
Restart = on-success

WantedBy = multi-user.target

I know how to do it if I use the redis_init_script found in redis/utils, but it has to be placed in the /etc/init.d. It does not work when placed in the lib/systemd/system.


You can create a systemd service override for this. For example:

# systemctl edit redis.service

ExecStop=/www/redis/redis-4.0.11/src/redis-cli -a mypassword shutdown

The first ExecStop= is necessary to discard the list of ExecStop= commands from the original unit.

Note that this is a custom redis systemd unit. The redis systemd unit that ships with Fedora (and the identical package built by remi for RHEL/CentOS) calls a shutdown script that reads the password from redis.conf and automatically passes it in redis-cli, so no customization is necessary. You might wish to use the distribution redis, or at least study its scripts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.