[Chicago-talk] Is it running from cron?
Andy_Bach at wiwb.uscourts.gov
Andy_Bach at wiwb.uscourts.gov
Thu Feb 22 09:26:08 PST 2007
> >
> FROM_CRON=1
> 1 2 3 4 5 /some/command some args
Couple hints - best to make a script and run that instead of a command, as
you can alter the script as needed. You can also set all the vars you
want. Modern (Vixie-ish) crons set some env vars (see
man 5 crontab
Several environment variables are set up automatically by the cron(8)
daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set from
the
/etc/passwd line of the crontabâs owner. HOME and SHELL may be
over-
ridden by settings in the crontab; LOGNAME may not.
(Another note: the LOGNAME variable is sometimes called USER on
BSD
systems... on these systems, USER will be set also.)
In addition to LOGNAME, HOME, and SHELL, cron(8) will look at
MAILTO if
it has any reason to send mail as a result of running commands
in
ââthisââ crontab. If MAILTO is defined (and non-empty), mail is
sent
to the user so named. If MAILTO is defined but empty (MAILTO=""),
no
mail will be sent.
...
Environment variables can be set in the crontab. In BSD or ATT,
the
environment handed to child processes is basically the one
from
/etc/rc.
But note - expansions *don't* work, e.g.
PATH=$PATH:/usr/local/bin
won't give (/bin:/usr/bin is the standard cron-given path ... so FQ
executable names is always worth it - even if it is /bin/grep)
PATH=/bin:/usr/bin:/usr/local/bin
but:
$PATH:/usr/local/bin
(just put:
PATH=$PATH:/usr/local/bin
6 11 * * * root /bin/echo $PATH
in /etc/cron.d/test - as long as the set time is more than a minute away
from now).
a
Andy Bach
Systems Mangler
Internet: andy_bach at wiwb.uscourts.gov
VOICE: (608) 261-5738 FAX 264-5932
"Procrastination is like putting lots and lots of commas in the sentence
of your life."
Ze Frank
http://lifehacker.com/software/procrastination/ze-frank-on-procrastination-235859.php
More information about the Chicago-talk
mailing list