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.
if [ ! -t 1 ]; then # We don't have a terminal, then we are in cron # Script running in cron, run without output else # Script running interactively, use verbose output fi
This script is POSIX shell compliant so runs everywhere.