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?
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.
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.