在我的Linux服务器上,我跑了:
sudo thin start -p 80 -d
现在我想重启服务器。 麻烦的是,我似乎无法让旧的程序杀死它。 我试过了:
netstat -anp
但是我在80号端口看到的是这样的:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
所以,它没有给我一个PID来杀死…
我尝试了pgrep -l thin但是没有给我什么。 同时pgrep -l ruby让我像6个进程运行。 我真的不明白为什么多个ruby线程将运行,或者我需要杀死哪一个线程…
如何杀死/重启瘦守护程序?
thin是Ruby的gem,所以Ruby解释器运行它是有道理的。
一个典型的thin调用将是:
bundle exec rails server thin -p $PORT -e $RACK_ENV
在进程列表中,从ps命令,这看起来像这样:
6870 pts/3 Rl+ 0:01 /usr/bin/ruby script/rails server thin -p 80 -e production
当使用pgrep ,默认情况下它只匹配命令名(即ruby )。 当您search的模式出现在参数中时,这将不匹配。 为此,您还需要使用-f选项:
pgrep -l -f thin
然后返回如下所示:
6870 /usr/bin/ruby script/rails server thin -p 80 -e production
瞧,这是你正在寻找的过程。
以root身份运行netstat -tulpn会在输出中给你PID。
[root@hostname ~]# netstat -tulpn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 3738/nrpe tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 12747/java tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 3273/snmpd tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 30110/python tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 12747/java tcp 0 0 0.0.0.0:8649 0.0.0.0:* LISTEN 19770/gmond tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1656/mysqld tcp 0 0 0.0.0.0:8651 0.0.0.0:* LISTEN 19794/gmetad tcp 0 0 0.0.0.0:8652 0.0.0.0:* LISTEN 19794/gmetad tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 12747/java tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1914/httpd tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 3885/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 13549/sshd tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 12403/postgres tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 15834/master udp 0 0 0.0.0.0:40462 0.0.0.0:* 3862/avahi-daemon udp 0 0 0.0.0.0:161 0.0.0.0:* 3273/snmpd udp 0 0 127.0.0.1:53 0.0.0.0:* 3885/dnsmasq udp 0 0 10.182.10.5:8649 0.0.0.0:* 19770/gmond udp 0 0 0.0.0.0:5353 0.0.0.0:* 3862/avahi-daemon udp 0 0 10.182.10.5:123 0.0.0.0:* 3335/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 3335/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 3335/ntpd