Path And 'cron'
Tim Daneliuk
tundra at tundraware.com
Mon Feb 20 19:28:58 PST 2006
Randy Pratt wrote:
<SNIP>
>> If I do not have a PATH= statement in a particular user's crontab,
>> what is used for a default PATH?
>
>
>>From "man 5 crontab" :
>
> Several environment variables are set up automatically by the cron
> (8) daemon. SHELL is set to /bin/sh, PATH is set to /usr/bin:/bin,
> and LOGNAME and HOME are set from the /etc/passwd line of the
> crontab's owner. HOME, PATH and SHELL may be overridden by
> settings in the crontab; LOGNAME may not.
>
I wonder if I can use the PATH=$PATH:/my/new/stuff formulation in
a crontab file to preserve this default. I'll have to look into that.
>> Is the path in /etc/crontab inherited somehow?
>>
>> Given that the default shell is /bin/sh, are the settings
>> in /etc/profile observed? If no PATH is established there either,
>> what will cron use?
>>
>>I am trying to determine the best place to establish correct global
>>PATH settings for all cron users so I don't have to edit each users'
>>crontab file when file locations are updated or changed.
>
>
> It seems that the PATH is being set in the source code, in particular
> /usr/src/usr.sbin/cron/cron/pathnames.h :
>
> #ifndef _PATH_DEFPATH
> # define _PATH_DEFPATH "/usr/bin:/bin"
> #endif
>
> I suppose its possible to change the source and rebuild but there may
> be subtle interactions that aren't readily apparent that would need to
> be considered. There may even be a knob to tweak somewhere for this.
That's what I was hoping for - tweaking the source is not a very
clean way to solve my problem.
In case you're interested (or anyone else listening), it seems that
'chown' likes to live in /usr/sbin - i.e., A place not in the default
path. As it happens, a root cron task is trying to run a script
that uses 'chown' and is thus failing. I can change the PATH just
for root's crontab and solve the problem. I was just curious if there
was a way to more broadly modify the defaults used by cron.
Thanks again, for your time in this matter ...
--
----------------------------------------------------------------------------
Tim Daneliuk tundra at tundraware.com
PGP Key: http://www.tundraware.com/PGP/
More information about the freebsd-questions
mailing list