My question:
I have an if statement in perl where I attempt to detect via environment variables at the time of launching the perl script whether it was launched via a cron job or via normal execution through the shell.
Is there any way to set an environment variable in the crontab itself that a program launched by cron would be able to access?
Essentially, I want this in the top of my crontab:
COMPANYCRON=1
* * * * * someperl.pl
And in someperl.pl this if statement:
if ( $ENV{'COMPANYCRON'} eq '1' ) {
$job_creator = "cron";
}
Is there a way to do this? Or a better approach to keeping track of cron jobs?