schernic
10/12/2017 - 11:04 AM

Debug service init script

debug_me=true

if [[ debug_me == true ]]; then

  # Close STDOUT
  exec 1<&-
  # Close STDERR
  exec 2<&-

  LOG_FILE=/home/myhome/scriptname.log

  # Open STDOUT as $LOG_FILE file for read and write.
  exec 1<>$LOG_FILE

  # Redirect STDERR to STDOUT
  exec 2>&1

  # Display shell commands with expanded args
  set -x

fi