Sudo in a cron job question

Tim Wunder tim
Mon May 17 11:44:36 PDT 2004


On 2/19/2003 9:24 AM, someone claiming to be Net Llama! wrote:
> On Wed, 19 Feb 2003, Tim Wunder wrote:
> 
>>Hi,
>>I've configured sudo so that I can execute checkinstall as my normal
>>user in an effort to automate the updating of gnucash from CVS. As far
>>as I can tell, sudo is working correctly. When I execute
>>/usr/bin/sudo checkinstall -R -y --pkgname=gnucash-CVS
>>--pkgversion=1.8.20030218 --provides=gnucash-CVS
>>from the command line, checkinstall is run, gnucash gets installed and
>>an RPM is built. It also works when the command gets executed from a script.
>>But, when the script is run as a cron job, it fails waiting for a password.
>>
>>What am I doing wrong?
>>
>>If you want to look at the script (my scripting skills are, um, basic,
>>to say the least...), you can find it here:
>>http://www.thewunders.org/files/gnucashUpdate
> 
> 
> Who are you running the cronjob as?  If you're doing this via a cronjob,
> why can't you just run the job as root?
> 

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.

Regards,
Tim




More information about the Linux-users mailing list