On Mon, 16 Sep 2013 12:26:59 +0100, Paul Macdonald wrote:
> 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.

I'd suggest the script creates a file (lock file or,
much easier, just a simple normal file) at its beginning:

        /usr/bin/touch /tmp/scriptrun
        # ... your script content here ...

You could also output the date command to that file
to see when the script has been called:

        /bin/date "+%Y-%m-%d %H:%M:%S" > /tmp/scriptrun
        # ... your script content here ...

Of course you would have to manually remove that file
after you have verified its existence and content.

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to