Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to set up cron jobs in ubuntu server. I always use crontab -e at root. I make sudo su - to login as root and then use crontab -e. But today I heard that is not smart to use cron jobs as root user. Is this true? Must I use general user and set cron jobs there?

share|improve this question
1  
There is no need for root to use crontab -e in Ubuntu. The preferred way for root to configure cron is via the system-wide crontabs: /etc/crontab, /etc/cron.d/, /etc/cron.daily/, etc. –  Steven Monday Jul 18 '12 at 14:51

2 Answers 2

up vote 3 down vote accepted

You should always try to work with the principle of least privilege. You should only give a job/user/service/... the bare minimum rights it needs to do its work.

Technically speaking, you could run everything as root, but you shouldn't. If one user/process/... has a vulnerability that allows them to execute something they should't (via a buffer overflow or something like that) they have direct root access. This is not possible (or less likely) with accounts with restricted permissions.

share|improve this answer
1  
Thank you for help and explanations –  senzacionale Jul 18 '12 at 12:39

Well it all depends if your job STRICTLY requires actions be ran as root. If your job doesnt require any you are better off setting your job to run on your regular user crontab.

share|improve this answer
    
just sending mails nothing else. I will move to general user ... –  senzacionale Jul 18 '12 at 12:38
    
Well just what Bart De Vos said, use the principle of least privilege. Again, depending on your scenario I dont think its needed. If you had a list of emails to send, you'd want the company's CEO to send them or your secretary? ;-) –  Rhyuk Jul 18 '12 at 12:43
2  
Depends a lot on how much you like the CEO, doesn't it? Personally, I send all my death threats from the CEO's account, because his secretary's always been nice to me. :o –  HopelessN00b Jul 18 '12 at 12:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.