13

so after installing redis onto my ubuntu 20.04 server. Whenever I reboot. A stop job appears for Advanced key-value store. I believe this is part of redis but I don't know why it keeps appearing and taking so long. How do I stop it

2 Answers 2

2

I had this issue too and the fix was pretty simple. You need to edit the redis service file defined by the command systemctl show -P FragmentPath redis.service :

$ systemctl show -P FragmentPath redis.service
/lib/systemd/system/redis-server.service

Look for the line that contains TimeoutStopSec and set it to the maximum value in seconds you want. I normally set it to 5 seconds.

After configuring the file, the line should look something like this

TimeoutStopSec=5s

Now that's it, you may want to run the command systemctl daemon-reload just to complement this.

You can then try rebooting or shutting down to confirm the change worked.

Bonus

If you want to set the maximum timeout for the entire system, you do so in the /etc/systemd/system.conf file.

Look for the line DefaultTimeoutStopSec and set it just as you did previously.

3
  • A couple of remarks: Systemd units normally reside inside /lib/systemd/system/ - I'm pretty sure any .service file inside /etc/systemd/system/ is a symlink that points to /lib/systemd/system/. And another thing: It's generally best to modify unit files by using drop-in configs. This means you should create the directory /etc/systemd/system/redis.service.d, and create a config file here (called redis.conf). And inside this file you would add the line TimeoutStopSec=5s. This means your custom config will survive if the unit file gets updated. Apr 21, 2022 at 11:06
  • 1
    Sure, thanks for the tip. Apr 21, 2022 at 11:21
  • redis.service links to redis-server.service in /lib/systemd/system/. With /lib/ instead of /etc/, folder should be /lib/systemd/system/redis-server.service.d/
    – skipbo
    Aug 2, 2022 at 19:39
0

check your /etc/redis/redis.log file for the reason why it cant restart.

For me, i had the following error:

1963:signal-handler (1670871763) Received SIGTERM scheduling shutdown...
1963:M 12 Dec 2022 14:02:43.145 # User requested shutdown...
1963:M 12 Dec 2022 14:02:43.145 * Saving the final RDB snapshot before 
exiting.
1963:M 12 Dec 2022 14:02:43.145 # Failed opening the temp RDB file temp-
1963.rdb (in server root dir /var/log) for saving: Read-only file system
1963:M 12 Dec 2022 14:02:43.145 # Error trying to save the DB, can't exit.
1963:M 12 Dec 2022 14:02:43.145 # Errors trying to shut down the server. 

Check the logs for more information.

To fix it i just ran the following to fix the problem.

sudo chown redis /var/log/redis/redis.log && sudo chmod u+x /var/log/redis/redis.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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