Running cron under sudo
Homer
fsunoles at gmail.com
Tue Oct 7 16:07:01 UTC 2008
On Tue, Oct 7, 2008 at 9:50 AM, Brian McKee <brian.mckee at gmail.com> wrote:
> On Tue, Oct 7, 2008 at 11:38 AM, Homer <fsunoles at gmail.com> wrote:
>> Ubuntu Server 8.04
>>
>> I can get cron to work as a regular user, but not sudo. For example:
>>
>> 23 8 * * * cp /root/test /root/test1
>>
>> will not run under sudo, but a similar cron will run as a regular user.
>>
>> 23 8 * * * cp /home/user/test /home/user/test1
>>
>> I'm entering sudo's cron with "sudo crontab -e"
>
> Try sudo su - and then crontab -e or sudo crontab -u root -e
>
> From the man page
>> If the -u option is given, it specifies the name of the user
>> whose crontab is to be tweaked. If this option is not given, crontab examines
>> "your" crontab, i.e., the crontab of the person executing the command.
>> Note that su(8) can confuse crontab and that if you are running inside of su(8)
>> you should always use the -u option for safety's sake.
Thank you for taking the time to reply. I'm assuming you meant "sudo
-i" as your first suggestion. I had already tried that without
success and your second suggestion doesn't work either. Strange thing
is, I have two identicals machines with identical installs. At least
I think they are identical. cron jobs with sudo work just fine with
one, but not at all with the other.
More information about the ubuntu-users
mailing list