I would like to have a service watchdog script echo the status to the screen if called like ./watchdog.sh but if it is run by cron, there is no need to echo output. What is the proper method? Where does stdout go when a script is run under root's crontab?
For the many cron jobs that I run, I purposely make them so if run on command line appropriate outout is generated but the same script if placed in crontab I always capture both the stdout and stderr to a log file:
00 12 * * 1-5 /home/aws/bin/myscript.sh >> /home/aswartz/rje/cron.log 2>&1
Cronjob output is sent to the user via the system's mail system.
You can check whether stdout is a terminal:
if [ -t 1 ]; then echo Terminal else # not a terminal, don't echo fi