Running cron under sudo

Derek Broughton news at
Wed Oct 8 19:06:53 UTC 2008

Brian McKee wrote:

> On Tue, Oct 7, 2008 at 12:56 PM, Derek Broughton <news at>
> wrote:
>> Brian McKee wrote:
>>>>> Try sudo su -  and then crontab -e
>>>> Thank you for taking the time to reply.  I'm assuming you meant "sudo
>>>> -i" as your first suggestion.
>>> Nope
>>>   sudo su -
>>> will log you in as root after you provide YOUR password.
>> No, he's right.  The "proper" way to get a root user shell is "sudo -i".
> I'm not sure about that.  I've read both man pages, and I'm not sure
> there's a difference. 

I'm not either, but I _know_ "sudo -i" gets you a proper login shell.

>>> Then crontab -e will work as expected.
>> Not according to man crontab(1).
> Yeah I know - I even quoted that section in my reply.   After
> re-reading it, you are probably right on this one.  I always read that
> as 'if you use su -c crontab -e' it might not work', but your
> interpretation could very well be the correct one.

I played with it a bit, and can't see a problem with doing it in a proper
shell, as opposed to "su -c crontab -e" or "sudo crontab -e", but it sure
looks to me like it says never to run it as a superuser with the -u option.

More information about the ubuntu-users mailing list