How to stop and restart memcached server?
Asked Answered
A

12

109

How to stop and restart memcached server 1.4.5 in linux OS from command line?

Annunciate answered 22/6, 2010 at 19:58 Comment(1)
can anybody help me in this #50135802Wives
B
128

Using root, try something like this:

/etc/init.d/memcached restart
Belting answered 22/6, 2010 at 20:2 Comment(3)
it did not work- is there a need to creare script to stop and start as service?Annunciate
well, 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.Belting
I had to add sudoMoiety
U
51

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.

Unsociable answered 17/12, 2011 at 23:50 Comment(5)
btw the dash after su is important, without it, it will report it can't find "service"Unsociable
This was the correct answer for me, running Ubuntu and memcached as a service. Without specificing service, it does not work.Charlet
If you don't have root, but sudo privileges: sudo service memcached restartDenn
on some systems sudo su - would work to change to root user.Unsociable
if you have sudo (on Debian-based systems) no need for su -Anesthesiology
M
29

If you're using homebrew:

brew services restart memcached
Merlon answered 5/6, 2014 at 2:23 Comment(2)
Note that services is now considered an external tool to brew. apple.stackexchange.com/questions/150300/…Consequently
...meaning you need to install it before you can use it: brew tap homebrew/servicesStudding
C
26
sudo service memcached stop

sudo service memcached start

sudo service memcached restart
Clava answered 20/5, 2013 at 7:22 Comment(0)
F
9

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

Farci answered 16/11, 2016 at 3:45 Comment(0)
M
7
sudo /etc/init.d/memcached restart
Moffett answered 13/12, 2012 at 9:30 Comment(0)
P
7

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
Proleg answered 2/9, 2015 at 8:39 Comment(0)
S
7

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
Swaziland answered 6/2, 2019 at 15:14 Comment(0)
P
6

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
Photoflash answered 11/12, 2015 at 4:18 Comment(0)
M
3

This worked for me:

brew services stop memcached
Mutiny answered 2/6, 2020 at 15:34 Comment(0)
G
1

If you have an older version of memcached and need a script to wrap memcached as a service, here it is: Memcached Service Script

Geosyncline answered 12/11, 2014 at 13:25 Comment(0)
C
1

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
Consequently answered 6/5, 2015 at 21:59 Comment(2)
You can use the -d switch to launch memcached as a daemon (bit cleaner than backgrounding it)Wingfooted
How do you stop memcached if you started it with memcached -d?Anachronous

© 2022 - 2024 — McMap. All rights reserved.