I'm trying to execute two commands in a single line:

pkill "something" && runsomething
  • when executing each command separately, both work.
  • When executed together with "&&", only the first one works

when using something other than pkill, it works:

 sleep 5 && runsomething

How can I make "pkill" play nice with multiple commands in a single line?

  • 1
    && tells the shell to run the second command only if the first succeeds (specifically, if it exits with a status of zero). Apparently, pkill is exiting with an error status. – Gordon Davisson Sep 13 '19 at 18:43
  • Yep. that was the reason. pkill failed. – JasonGenX Sep 13 '19 at 18:50

I think you need to put a semi-colon between the two commands instead of &&. I just tried using the semi-colon and it worked fine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .