Bash script problem
Hello,
I have a problem with a bash script. The script (example) is very simple:
----script.sh-----------------------
#!/bin/bash
echo hello
ssh PT-AGCMLX1 "while true; do date; sleep 10s; done"
------------------------------------
When I start script.sh, look up its pid via ps and kill it, the ssh keeps
running:
9311 pts/4 S+ 0:00 /bin/bash ./script.sh
9312 pts/4 S+ 0:00 ssh PT-AGCMLX1 while true; do date; sleep 10s;
done
> kill 9311
9312 pts/4 S 0:00 ssh PT-AGCMLX1 while true; do date; sleep 10s;
done
How can I change my script so that it kills all its child processes, if it
is killed itself ? I tried to use the "trap" function of bash, but it
never used the correct pid...
Many thanks for your help,
Markus Grunwald
Softwareentwicklung
PRÜFTECHNIK Condition Monitoring GmbH
Oskar-Messter-Straße 19-21
85737 Ismaning
www.pruftechnik.com
Tel: +49 (0)89 99616177
Fax: +49 (0)89 99616200
Reply to: