Sudo in a cron job question
Net Llama!
netllama
Mon May 17 11:44:36 PDT 2004
On Wed, 19 Feb 2003, Tim Wunder wrote:
> The cron job belongs to my user, based on the fact that executing
> 'crontab -e' as my user lists the job, and the log file that's created
> is owned by me.
>
> I imagine I *could* run the job as root (heck, I could do *everything*
> as root, couldn't I?). If I run the job as root, then my source tree
> would become owned by root, so I'd either have to change ownership back
> to me when I want to manually update, or always update as root. Seems
> contrary to the genreally accepted practice of running as root as little
> as possible, though. And it doesn't address the question of why sudo
> doesn't seem to work when part of a cron job, but works swimmingly when
> run from the same script manually.
I think that's because cronjobs do not inherit the environment of the user
that they are running as. So, all the env vars etc are not in play.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lonni J Friedman netllama at linux-sxs.org
Linux Step-by-step & TyGeMo http://netllama.ipfox.com
More information about the Linux-users
mailing list