cronjob with highest privilege

I have a FreeBSD and ubuntu server.
I crate a cronjob to execute in specific time. but the command that I do required a full privilege on system... so how I can make the cronjob work with root for example ?
Amin El-ZeinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
You do something like this...

sudo crontab -e

Open in new window

This will put you into the CRON entries for the root user.
Zerox HoopLinux AdminCommented:
First you need to add user in /etc/sudoers file.
and add below-mentioned line.


After run  #crontab -e
 * * * * * /usr/bin/sudo /command or else script you want to run

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gerwin Jansen, EE MVETopic Advisor Commented:
You can either just logon as root and create the crontab entry or create a crontab entry and get sudo rights for the command (or commands) that need higher privileges. I'm preferring the last as it enables you to test your script more easily and you don't have to put anything in the root crontab. What command are you trying to run btw?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.