Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Sep 2013 08:21:48 -0400
From:      Jerry <jerry@seibercom.net>
To:        FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: test if script called by cron
Message-ID:  <20130916082148.5749c31c@scorpio>
In-Reply-To: <5236EB03.7040001@ifdnrg.com>
References:  <5236EB03.7040001@ifdnrg.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 16 Sep 2013 12:26:59 +0100
Paul Macdonald articulated:

> 
> Hi,
> 
> Is there a simple way of testing whether a given script was called
> via cron,
> 
> I'd rather find a solution that would work from within the script
> rather than setting an environment variable in the crontab.
> 
> thanks
> Paul.
> 
> (anyone here going to EuroBSD con?)

If you want to learn if the running script was called via cron, this
would work, assuming you are running Bash.

	if [[ ! -t 0 ]]; then
		echo "Running from Cron"
	fi

-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130916082148.5749c31c>