[ale] Bash: How to determine if called from cron?
Christopher Fowler
cfowler at outpostsentinel.com
Mon Jun 27 09:46:06 EDT 2005
That won't work either. I think tty does a isatty check. My script
that looks like this:
#!/bin/sh
FD1=`ls -l /proc/$$/fd/1 | cut -d '>' -f2`
echo $FD1 >> /tmp/test.sh.out
Gave me this:
[cfowler at cfowler tmp]$ tail /tmp/test.sh.out
pipe:[266205]
pipe:[267448]
pipe:[268442]
pipe:[269312]
On Mon, 2005-06-27 at 09:24, David A. De Graaf wrote:
> On Mon, Jun 27, 2005 at 12:17:00AM -0400, Christopher Bergeron wrote:
> > Does anyone know of an easy way for my script to determine if it's being
> > run from cron or from a user shell?
>
> Read about the 'tty' command.
> Try this example script, both manually and via cron:
>
> ANS=`tty`
> echo ANS: $ANS
More information about the Ale
mailing list