WebFaction
Community site: login faq

I've got memcached set up, and it's integral to the performance of one of my sites. Following WF's instructions, memcached will restart if the server is rebooted. But if only memcached crashes, it doesn't restart automatically, and it takes the website down with it.

How can I set it up so that memcached will restart automatically if it crashes?

asked 06 Mar '15, 21:53

PeterA
10431022
accept rate: 14%


You would need to set up a cronjob to run a script something like the following. It could be set to run every 5 minutes for example.

#!/bin/bash

if ps -u <username> |grep -E 'memcached$' > /dev/null
then
  echo "memcached is running."
else
  echo "starting memcache."
  rm /home/<username>/webserver/sock/memcached.sock
  rm /home/<username>/webserver/pid/memcached.pid
  /usr/bin/memcached -d -m 50 -s /home/<username>/webserver/sock/memcached.sock -P /home/<username>/webserver/pid/memcached.pid
fi
permanent link

answered 06 Mar '15, 22:32

bmeyer71 ♦♦
1.5k3613
accept rate: 33%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×34

question asked: 06 Mar '15, 21:53

question was seen: 3,412 times

last updated: 06 Mar '15, 22:32

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM