How can I do this? Im running RedHat x86_64 es5. I heard that a cron job is possible, and some other people talk about a script?

Note that my linux server knowledge is very limit, so please be thorough if you will kindly assist me.

  • This question has been resolved with the assistance of ABrown and Tom O'Connor. – Peter Johansson Nov 15 '10 at 14:06
chkconfig --level 2345 memcached on

It is possible, that the --level bit isn't required, but does give finer control

chkconfig memcached on

should work too..

The first one will turn memcached on (ie, start the daemon) whenever runlevels 2,3,4,5 are entered. i.e. startup.

This assumes that /etc/init.d/memcached is in the right place, but if you installed it from packages, it should be fine.

  • Tom, "chkconfig --level 2345 memcached on" will make it always boot on server startup? Meaning that I will not need to setup a cron job?? – Peter Johansson Nov 15 '10 at 13:58
  • Don't set up a cron job to start services. Cron is designed for recurring events. You want this to happen once, and be triggered by the server boot event, not every n minutes. – Tom O'Connor Nov 15 '10 at 14:00
  • Also, I just ran "chkconfig --level 2345 memcached on" but I didnt get any respond from it which is unusual...? Is there any way to check that the command did even work?? – Peter Johansson Nov 15 '10 at 14:00
  • 1
    chkconfig --list memcached will show you if it worked. If you don't have an /etc/init.d/memcached file, this won't get the job done. – Aaron Brown Nov 15 '10 at 14:03
  • memcached 0:off 1:off 2:on 3:on 4:on 5:on 6:off – Peter Johansson Nov 15 '10 at 14:05

A few options...First, cron is not the place for this.

If you have installed memcached from source (which there is little reason to do unless you have some very specific need), you can either:

  1. Add the memcached start command (it would look something like "/usr/local/bin/memcached -d -p 11211 -u nobody -m 1024") to /etc/rc.local
  2. write or find an /etc/init.d/memcached somewhere on the interwebs, drop it in/etc/init.d, and call:
chkconfig --add memcached
chkconfig memcached on
  1. Install monit and configure monit to monitor and control the memcached service.

In my opinion, the best and simplest option is to install the memcached package from the EPEL repository with yum, in which case, you run the chkconfig command above to enable it at start up. With the EPEL packages, you will edit /etc/sysconfig/memcached to control the memcached bucket settings instead of calling the memcached binary with parameters directly.

Good luck.

  • Perhaps I'm old fashioned, but I don't like the sound of having Yet Another Process Supervisor on my system. Init (or upstart) does a pretty good job. I'm all for monitoring, but it should be ME who makes the changes to system state. – Tom O'Connor Nov 15 '10 at 14:08

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.