in reply to Re: Detecting running from cron?
in thread Detecting running from cron?

Official, portable, and solves a different problem. -t tells you whether a filehandle is connected to a TTY; it does not tell you whether you are running from the command line.

Any filehandle you can test with -t can be redirected on the command line. Using -t to ask "is the script running from the command line?" will result in false negatives.

P.S. Did you mean tye's method?