in reply to Detecting running from cron?

Hm, good question: how for a script to determine how it was invoked: command line vs. crontab.

The only thing I can offer is that when run from crond, different environment variables are set. The one that seems to be helpful is $TERM. When a script is run from crond, at least on my Redhat 6.x system, TERM is set to "dumb".

So maybe something like:

if ($ENV{TERM} eq 'dumb') { ## redirect stdout to stderr open STDOUT,">&STDERR"; ## I think :) } print "This will go to stderr if running from crond\n";