How to stop and restart memcached server 1.4.5 in linux OS from command line?
12 Answers
Using root, try something like this:
/etc/init.d/memcached restart
-
it did not work- is there a need to creare script to stop and start as service?– smritiJun 23, 2010 at 15:56
-
3well, it realy depends on your linux distribution and how you did install memcache. If you hav installed package of your distribution there should be memcached start/stop script (maybe it is in different directory like /etc/rc.d) If you installed memcached manualy you probably need also create star/stop script by yourself.– pejukoJun 23, 2010 at 17:11
-
Log in as root or do
su -
Then:
service memcached restart
If that doesn't work, then:
/etc/init.d/memcached restart
It all depends on which Linux distro (or other OS) you're using.
-
btw the dash after su is important, without it, it will report it can't find "service" Dec 17, 2011 at 23:51
-
2This was the correct answer for me, running Ubuntu and memcached as a service. Without specificing service, it does not work. Aug 5, 2012 at 14:08
-
2If you don't have root, but sudo privileges:
sudo service memcached restart
– danritiFeb 27, 2013 at 15:32 -
-
If you're using homebrew:
brew services restart memcached
-
Note that
services
is now considered an external tool to brew. apple.stackexchange.com/questions/150300/…– KirbyMay 6, 2015 at 21:54 -
...meaning you need to install it before you can use it:
brew tap homebrew/services
– wxactlySep 23, 2015 at 0:26
sudo service memcached stop
sudo service memcached start
sudo service memcached restart
if linux
if install by apt-get
service memcached stop
service memcached restart
if install by source code
Usage: /etc/init.d/memcached {start|stop|restart|force-reload|status}
can also simply kill $pid to stop
As root on CentOS 7:
systemctl start memcached
systemctl stop memcached
systemctl restart memcached
To tell the service to start at reboot (ex chkconfig):
systemctl enable memcached
To tell the service to not start at reboot:
systemctl disable memcached
To shutdown memcache daemon:
sudo service memcached stop
To start memcached daemon:
sudo service memcached start
Restart memcached server:
sudo service memcached restart
You can see if Memcache is currently runing:
sudo ps -e | grep memcached
And you can check the TCP or UDP ports if something (e.g. Memcache) is listening to it:
netstat -ap | grep TheChosenPort#
netstat -ap | grep 11211
For some Linuxes you need to change your commands like:
sudo /etc/init.d/memcached start
sudo /etc/init.d/memcached restart
sudo /etc/init.d/memcached stop
If you want to be allowed to shutdown the memcached server you can give it that option before start it :
memcached -A &
With this option when you connect to memcached server for example:
telnet localhost 11211
then you can use shutdown
command to shutdown the server. You can also shutdown the memcached server when it is run as a process, first find the process PID using:
pidof memcached
then use:
kill PID command
If you have an older version of memcached and need a script to wrap memcached as a service, here it is: Memcached Service Script
For me, I installed it on a Mac via Homebrew and it is not set up as a service. To run the memcached
server, I simply execute memcached -d
. This will establish Memcached server on the default port, 11211.
> memcached -d
> telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
version
VERSION 1.4.20
-
1You can use the -d switch to launch memcached as a daemon (bit cleaner than backgrounding it)– carpiiJun 23, 2015 at 0:19
-
2