【发布时间】:2018-08-20 23:03:01
【问题描述】:
我正在尝试终止 EC2 实例中的 nohup 进程,但到目前为止没有成功。我正在尝试获取进程 ID (PID),然后在终端中将其与 kill 命令一起使用,如下所示:
[ec2-user@ip-myip ~]$ ps -ef |grep nohup
ec2-user 16580 16153 0 19:50 pts/0 00:00:00 grep --color=auto nohup
与列,(我相信)他们是:
UID PID PPID C STIME TTY TIME CMD
ec2-user 16580 16153 0 19:50 pts/0 00:00:00 grep --color=auto nohup
但是,每次我尝试终止进程时,都会收到一条错误消息,指出 PID 不存在,这似乎是因为 PID 已更改。这是我在命令行中遇到的一个序列:
// first try, grab the PID and kill
[ec2-user@ip-myip ~]$ ps -ef |grep nohup
ec2-user 16580 16153 0 19:50 pts/0 00:00:00 grep --color=auto nohup
[ec2-user@ip-172-31-41-213 ~]$ kill 16580
-bash: kill: (16580) - No such process
// ?? - check for correct PID again, and try to kill again
[ec2-user@ip-myip ~]$ ps -ef |grep nohup
ec2-user 16583 16153 0 19:50 pts/0 00:00:00 grep --color=auto nohup
[ec2-user@ip-172-31-41-213 ~]$ kill 16583
-bash: kill: (16583) - No such process
// try 3rd time, kill 1 PID up
[ec2-user@ip-myip ~]$ ps -ef |grep nohup
ec2-user 16584 16153 0 19:50 pts/0 00:00:00 grep --color=auto nohup
[ec2-user@ip-myip ~]$ kill 16585
-bash: kill: (16585) - No such process
现在这对我来说相当困难,因为我需要杀死/重新启动这个 nohup 进程。任何帮助表示赞赏!
编辑 - 我尝试了这种方法来终止进程,因为它在此线程 (Prevent row names to be written to file when using write.csv) 中作为答案发布,并且是评分第二高的答案。
【问题讨论】:
标签: shell command-line nohup