Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

sudo apt-get install redis-server

That will create a redis user and install the init.d script for it. Since upstart is now the replacement for using init.d, I figure I should convert it to run using upstart.

To disable the default init.d script for redis:

sudo update-rc.d redis-server disable

Then create /etc/init/redis-server.conf with the following

description "Redis Server"
author "Thomas Woolford <>"

# run when the local FS becomes available
start on local-filesystems
stop on shutdown

# The default redis conf has `daemonize = yes` and will naiively fork itself.
expect fork

# Respawn unless redis dies 10 times in 5 seconds
respawn limit 10 5

# start a default instance
instance $NAME
env NAME=redis

# run redis as the correct user
setuid redis
setgid redis

# run redis with the correct config file for this instance
exec /usr/bin/redis-server /etc/redis/${NAME}.conf

What this is is the script for upstart to know what command to run to start the process.

Now you can use the folowing commands to control your redis-server:

sudo start   redis-server [ name=redis ]
sudo restart redis-server [ name=redis ]
sudo status  redis-server [ name=redis ]
sudo stop    redis-server [ name=redis ]

Hope this was helpful!


This comment has been minimized.

Copy link

@rogerleite rogerleite commented Jul 4, 2013


This comment has been minimized.

Copy link

@mreishus mreishus commented Sep 18, 2013

shouldn't you set
env NAME=redis
before doing
instance $NAME


This comment has been minimized.

Copy link

@lenn4rd lenn4rd commented Jan 24, 2014

On Ubuntu 10.04, Upstart doesn't have the setuid and setgid options. Uncomment them and start redis with the start-stop-daemon helper as per

exec start-stop-daemon --start -c redis:redis --exec /usr/bin/redis-server /etc/redis/${NAME}.conf


This comment has been minimized.

Copy link

@line-o line-o commented Mar 5, 2014

This version of the redis upstart script works very well on ubuntu14.04LTS. Thank you very much @twoolie.


This comment has been minimized.

Copy link

@juriglx juriglx commented Feb 24, 2015

you can also increase the file limit with:
limit nofile 10032 10032


This comment has been minimized.

Copy link

@hawko2600 hawko2600 commented Apr 15, 2015

For versions of upstart that setuid/setgid doesn't exist in because they're 4 years / 21 major versions behind (Hi Redhat!), you can have redis start as another user by exploiting functionality of chroot

exec chroot --userspec redis:redis / /usr/local/bin/redis-server /usr/local/etc/${NAME}.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment