【问题标题】:Process ID of nohup process continually updating - cant kill processnohup 进程的进程 ID 不断更新 - 无法杀死进程
【发布时间】: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


    【解决方案1】:

    非常非常糟糕的问题...

    1. 你正试图杀死你 grep 进程...

      ec2-user 16580 16153  0 19:50 pts/0    00:00:00 grep --color=auto nohup
      

    命令是grep --color=auto nohup

    1. 我不确定你能不能杀死 nohup

    nohup 将以特定方式运行您的命令。但是在它启动之后,nohup 进程就死掉了。

    【讨论】:

    • 在我把这件事搞砸之前你能详细说明一下吗?
    【解决方案2】:

    如果你想grep ps 输出:

    ps -ef | grep '[n]ohup'
    

    pgrep -fl nohup
    

    因为你试图杀死的不是 nohup pid 而是 grep 本身...

    【讨论】:

      猜你喜欢
      • 2015-01-06
      • 2013-06-27
      • 1970-01-01
      • 2011-12-21
      • 1970-01-01
      • 1970-01-01
      • 2013-08-05
      • 2015-06-08
      • 2015-06-01
      相关资源
      最近更新 更多