If two jobs are entered into bash command line separated by semicolon:
$ job 1; job 2;
How do I cancel the second one? If I press CTRL+c, the first one will be canceled and 'job 2' would start, I just want to stop second job not to be executed. I tried atq, ps but no luck, with ps -ef I can see only 'job 1' but 'job 2' is not listed, so I can not get PID to use kill. I know I can use && instead of ; but it is too late now, I ran this command by accident on my server instead of my home PC and now I am trying to figure out how to prevent a disaster.
This problem is specific to rsync command followed by another command:
$ rsync ..... ; sudo shutdown -h now
Killing process by ID or killing it's parent will not work.
After several hours of testing, I isolated it to rsync, other commands I am able to terminate with CTRL+c in various orders, but not if they are after some commands like rsync or ping, I tried different Ubuntu versions, kernels, server without sudo user and I could reproduce it everywhere, best way to avoid this problem is to use && after rsync to execute following command only on success exitcode 0:
$ rsync .... && job 2