in reply to Checking for STDIN

Shell scripts tend to use the $- environment variable in order to distinguish between interactive and non-interactive e.g. cron, invocations - it being set for interactive invocations.

HTH,

Update

Note, also, that if invoked non-interactively e.g. by cron(1), the environment is very basic i.e. none of the login scripts will have been run, so it's always best to invoke them in the cron(1) command e.g. * * * * * . $HOME/profile ; some_cmd > /dev/null 2>&1

At last, a user level that overstates my experience :-))