If I run ./script.sh &
, where script is the following:
#!/bin/bash
echo "hello"
sleep 30
echo "hello again"
sleep 30
touch /root/foo.txt
Then I use ps au, to identify the "sleep" call process id, which I subsequently terminate, via kill -HUP . The program then finishes still. Will the child "sleep" notify its parent?
However, if I run echo "hello" && sleep 30 && echo "hello again" && sleep 30 && touch /root/testFILE.txt &
, and repeat the process, the program does not finish. Why is this? It does in fact "touch" the file, if, during the last "sleep", I disconnect (as I am connected via ssh to an ec2 instance, running amazon linux 2, over ssh).
The disconnect should send a HUP signal to the sleep command (I think), which should have the same results as in the above paragraph but, lo and behold, upon my return the file is there....
(note: if I manually, via kill -HUP , send the the hup signal during this last "sleep", the file isn't created either...) What is going on? Is there any chance it is related to it being an ec2 instance or is this solely explainable by the unix os?