Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

/opt/eduserver/eduserver gives me options:

Usage: /opt/eduserver/eduserver {start|stop|startphp|startwww|startooo|stopphp|stopwww|stopooo|restartphp|restartwww|restartooo|status|restart|reload|force-reload}

where memcache is php module there is memcache.ini in /opt/eduserver/etc/php/conf.d.

I want to clear the memcache from command line. Can I do it somehow without 'touching' any other part of the web server?

share|improve this question
up vote 64 down vote accepted

yes. you can clear the memcache. try:

telnet localhost 11211

if the memcache does not run on localhost 11211, you will have to adjust it.

share|improve this answer
Can I do this non interactively? – Radek Apr 13 '11 at 23:54
I'm trying to verify this actually was effective. So far stats still shows total_items 3926. I was expecting total_items to drop to 0. Is that not how to verify the cache was flushed? – Danny Armstrong Jun 4 '13 at 18:01
@DannyArmstrong, flush only marks items as expired. Memcache doesn't remove expired items from the cache straight away for performance reasons. You can get expired items, so they have vanished from an API perspective – TerryE Jul 29 '14 at 17:52

This will also work using netcat

echo "flush_all" | nc -q 2 localhost 11211 

Then just wait for the "OK".

share|improve this answer
w/o hardcoded 2 seconds: printf "flush_all\nquit\n" | nc -q -1 127.1 11211 – zhangyoufu Apr 30 '15 at 15:50
OSX needs -w for timeout: echo "flush_all" | nc -w 2 localhost 11211 – mahemoff Oct 14 '15 at 6:51

memcflush in the memcache tools is what you want:

memcflush --servers=localhost:11211

Change localhost to whatever your server is.

The memcache tools may not be installed on the server, if you're running a Debian-based OS you can install it like this:

sudo apt-get install libmemcached-tools
share|improve this answer
In Red Hat distributions, the utility is included in libmemcached. – Kevin May 23 at 18:44

(sleep 2; echo flush_all; sleep 2; echo quit; ) | telnet 11211

if you want to run it non-interactively

thanks to @heiko

share|improve this answer

In Bash you may use this fancy syntax:

echo flush_all > /dev/tcp/localhost/11211

Otherwise use memflush command:

memflush --servers=localhost
share|improve this answer

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.