Skip to content

Instantly share code, notes, and snippets.

@lidio601
Created January 11, 2016 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lidio601/c690047e58b45e53c95b to your computer and use it in GitHub Desktop.
Save lidio601/c690047e58b45e53c95b to your computer and use it in GitHub Desktop.
In Bash scripting when you want to print useful information when debugging a script from terminal but not when executed in background (like from crontab)
#!/bin/bash
if [ -t 1 ]
then
: # running from terminal
debug="1"
else
: # not running from terminal, cron maybe
debug="0"
fi
if [ "$debug" -eq "1" ]; then
echo "Printing my debug information"
fi
# blablabla useful code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment