run bash script with trace


bash:

# run bash script with trace
bash -e -x ./script.sh
# enable trace for part of script
set -x
# disable trace for part of script
set +x

Printing the lines a bash script actually executed can be useful. Actually I would suggest you always run your scripts with this option and keep the log just in case something happens, you can always go back to find out when and why. Please note I also use “-e” option when using bash to start my script, this option will let script stop when a command in script will return with an error code, normally non-zero value. Please refer to this post for details.

, ,

  1. Leave a comment

Leave a comment