Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I launch memcached on boot?

share|improve this question
What system / version / os?? – Arenstar Nov 13 '10 at 17:31

Why cron???

If its installed on Debian ( use rcconf ) or

update-rc.d memcached defaults

If its installed on Redhat,Fedora,Centos,Suse

chkconfig memcached on

If its installed on windows..

Dont Know, But suggest you install it on Linux :P
share|improve this answer

Since you included cron as part of the question, I'm going to assume you are looking to do this on a UNIX or UNIXlike systems (Linux, *BSD, Solaris, etc). Although you could be trying to do this with cygwin.

This is not the normal method of starting services but it can be done. Running things from cron can be a way to ensure a critical service is restarted if it fails. You will need to write a wrapper script that checks if memcached is already running then starts it if it isn't. Then put entries in the cron.

The wrapper script will look in part like:

if ps -C memcached 2>/dev/null | grep -q memcached 2>/dev/null ; then

if [ ! $MEMCACHED_RUNNING ]  ; then
    memecached $options

Some enhancements that you should consider for this would be a check to ensure that memcache is not only running but returning values to key requests. That is is a bit beyond the scope of your question.

Then call the full script from cron. A cron entry in /etc/crontab would look like

*/5 * * * * user /path/to/memcached_restart_script 

In a user cron it would look like

*/5 * * * * /path/to/memcached_restart_script 

Most UNIX variants support the use of startup scripts. In SysV like systems like Solaris and Linux these are files named (servicename) stored in /etc/init.d with a link or symlink named S(nn)(servicename) in a directory like /etc/rc2.d, /etc/rc3.d, or /etc/rc5.d. In the BSD variants the script is stored under /usr/local/etc/rc.d or similar.

RHEL variants (RHEL, CentOS, Fedora, Scientific Linux, etc) can manage the scripts for you with a tool named chkconfig (chkconfig memcached on). Debian and ubuntu have a tool named update-rc.d (update-rc.d memcached defaults) Others have different methods.

Best Regards Rik

share|improve this answer

Presuming linux-ish cron (ISC cron aka vixiecron, actually),

@reboot /path/to/memcached/start/script

will start memcached once at startup. man 5 crontab has more details.

share|improve this answer
Very interesting... It makes sense for non daemon scripts, Why would you just not use standard init start? – Arenstar Nov 14 '10 at 3:30
...because you can do this as an unprivileged user. – pjz Nov 16 '10 at 22:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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