Для примера предположим, что я настроил ключ SSH.
Код: Выделить всё
ssh server1 'pkill -f proces1_name; echo $?'
возвращает нет выводов.ssh server1 'pkill -f proces2_name'< /code>
echo $?< /code>
output: 0 (Expecting 1)
ssh server1 'pkill -f proces1_name'< /code>
echo $?< /code>
output: 0 (Correct, should be killing something)
If I then run it again, I get
ssh server1 'pkill -f proces1_name'< /code>
echo $?< /code>
output: 0 (Incorrect, already killed above.)
Running it locally on the server, I get the expected output:
pkill -f proces1_name< /code>
echo $?< /code>
output: 1
Questions:
- How can I correctly fire a pkill over SSH without it killing its own (parent) proces?
- How can I capture the return code of this proces over SSH and then use it in my logic?
Подробнее здесь: https://stackoverflow.com/questions/796 ... n-it-didnt