Sudo in a cron job question
Tim Wunder
tim
Mon May 17 11:44:36 PDT 2004
On 2/19/2003 12:07 PM, someone claiming to be Condon Thomas A KPWA wrote:
> Tim Wunder <mailto:tim at thewunders.org> typed thusly on Wednesday, February
> 19, 2003 7:31 AM:
>
>
>>On 2/19/2003 9:24 AM, someone claiming to be Net Llama!
>>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.
>
>
> Couldn't you run the script that works so well as a cron job?
>
Um, no. I *am* trying to run the working script via a cron job, as my
normal user. But it don't work. I've configured sudo so that it doesn't
ask for a password when my user tries to run 'sudo checkinstall'. When I
put that in my script and execute it from the command line, checkinstall
runs and I don't need to enter my password. When the script is executed
as a cron job, sudo asks for a password, which never comes, so the
script fails.
I'm afraid it looks like the only way to accomplish it is to run it as
root. But I'm still searching...
Thanks,
Tim
More information about the Linux-users
mailing list