Detect if your Script is Running in CRON
In my previous post I discussed how I use a wrapper script to back up a fleet of servers.
Here I will just post the part about detecting the terminal/CRON, thought this might be useful and worth putting in a separate post making it easier for crawlers to find.
1if [ ! -t 1 ]; then # We don't have a terminal, then we are in cron
2 # Script running in cron, run without output
3else
4 # Script running interactively, use verbose output
5fi
This script is POSIX shell compliant so runs everywhere.