in reply to Detecting cron

From my cron manpage:
The shell is invoked from your $HOME directory with an arg0 of sh. Users who desire to have their .profile executed must explicitly do so in the crontab file. cron supplies a default environment for every shell, defining HOME, LOGNAME, SHELL(=/bin/sh), TZ, and PATH. The default PATH for user cron jobs is /usr/bin; while root cron jobs default to /usr/sbin:/usr/bin. The default PATH can be set in /etc/default/cron; see cron(1M).

So the usual mechanism is to look for the existance of some environment variable, other than those mentioned. And make sure that it's set nice and early for an interactive login.

Or there's the perlfaq. Or just the fact that cron jobs have their STDIN closed, so any attempt to read from it will simply return EOF, and not hang.

--
Tommy
Too stupid to live.
Too stubborn to die.