I run a remote script using ssh:
local script:
local_command
ssh -p 222 user@server 'sh -s' < ./remote_run.sh
remote script:
some_command &
sleep 10000
trap 'echo exiting' SIGINT SIGTERM SIGABRT SIGKILL EXIT
I need a trap on remote script for cleaning up (kill running processes and remove files). But used approach does not work.
Any suggestions?