小编Moh*_*han的帖子

pkill通过远程ssh返回255和另一个命令的组合

当我尝试在远程主机上结合另一个命令执行pkill时,即使两个命令都成功,它也始终返回255。

例子

  1. ssh <remoteHost> 'pkill -f xyz' # returns 0 (rightly so when xyz is a process)
    
    Run Code Online (Sandbox Code Playgroud)
  2. ssh <remoteHost> 'source /etc/profile' # returns 0 (rightly so)
    
    Run Code Online (Sandbox Code Playgroud)

但是当我运行组合命令时:

  1. ssh <remoteHost> 'source /etc/profile; pkill -f xyz' # returns 255 - why?
    
    Run Code Online (Sandbox Code Playgroud)

关于“ pkill”与另一条命令的结合是有一些问题的,因为即使结合使用,以下内容也会返回零:

  1. ssh <remoteHost> 'source /etc/profile; ls' # returns 0
    
    Run Code Online (Sandbox Code Playgroud)

假设xyz当我们试图杀死它时,它始终在运行。

我不了解这种行为。为什么在情况3中返回255?

linux ssh pkill

3
推荐指数
1
解决办法
943
查看次数

标签 统计

linux ×1

pkill ×1

ssh ×1