I need to run a few scripts every few minutes. The logic was made in PHP, and it's working great. To keep things together I've made the bash script below, which also runs fine.
#!/bin/bash calculaDiff() { DIFF=0 while [ "$DIFF" -eq "0" ]; do DIFF=`php calculaDiff.php` done; } # need to calculate pending diffs calculaDiff # main loop while true; do CAPTURA=`php capturaRelatorio.php` if [ "$CAPTURA" -eq "0" ]; then calculaDiff fi VERIFICA=`php verificaLimites.php` done The script capturaRelatorio.php has a sleep inside it because I can only process it every N minutes. It will print a message saying that it's sleeping for S seconds so I can monitor it.
If I call the bash script and press Ctrl+C at this time, while it's sleeping, it kills the bash script, but doesn't kill the called php script. I understand that there's a different process running it.
So, is there a way to kill the bash script and every "child"? Or should I go with another approach to run these scripts?