When I try to execute pkill on a remote host in combination with another command, it always returns 255, even though both the commands were successful.
Examples
ssh <remoteHost> 'pkill -f xyz' # returns 0 (rightly so when xyz is a process)
ssh <remoteHost> 'source /etc/profile' # returns 0 (rightly so)
But when I run the combination command:
ssh <remoteHost> 'source /etc/profile; pkill -f xyz' # returns 255 - why?
There's something about "pkill" in combination with another command because the following returns zero even though it's a combination:
ssh <remoteHost> 'source /etc/profile; ls' # returns 0
Assume that xyz
is running at all times when we try to kill it.
I do not understand this behavior. Why does it return 255 in case 3?