4

I have two scripts. First one is basically wrapper that calls subscript and sets timeout.

#!/bin/bash
# wrapper_script

timeout --signal=SIGTERM 50 main_script.sh

And if execution of main_script.sh takes longer than 50 s, I am trying to catch SIGTERM

#!/bin/bash
# main_script.sh

trap "echo 'Reached time limit'; rm $log_file; exit" SIGHUP SIGINT SIGTERM

I never get message "Reached time limit" printed, child script gets killed, but it does not catch SIGTERM. Do I miss something?

1 Answer 1

1

At least in the example you provided, your main_script.sh is going to exit immediately after the trap statement. If I add while :; do :; done to the end of your main_script.sh I get the "Reached time limit"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .