Starting a process over ssh using bash and then killing it on sigint
问题 I want to start a couple of jobs on different machines using ssh. If the user then interrupts the main script I want to shut down all the jobs gracefully. Here is a short example of what I'm trying to do: #!/bin/bash trap "aborted" SIGINT SIGTERM aborted() { kill -SIGTERM $bash2_pid exit } ssh -t remote_machine /foo/bar.sh & bash2_pid=$! wait However the bar.sh process is still running the remote machine. If I do the same commands in a terminal window it shuts down the process on the remote