Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

/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

4 Answers 4

up vote 29 down vote accepted

yes. you can clear the memcache. try:

telnet localhost 11211
flush_all
quit

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

share|improve this answer
2  
Can I do this non interactively? –  Radek Apr 13 '11 at 23:54
1  
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 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

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

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

if you want to run it non-interactively

thanks to @heiko

share|improve this answer

Your Answer

 
discard

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.