# cron, emerge --sync and root

## branchcut

Hi all,

I'm very new to cron so I don't know the pitfalls or "best practices" of using this tool. I'm using vixie-cron.

I'd like to run emerge --sync at 3:30 am every morning. Not hard, I guess I just add this line to my crontab:

30      3       *       *       *       /usr/bin/emerge --sync

But now...which user do I use? Who's crontab? The emerge --sync command only works as root, so I guess the easy answer would be to run it as root. But is this a security risk? Is there a better way to do it?

Is it literally just a matter of editing root's crontab and that's it?

Thanks for any tips,

Desmond

----------

## xoomix

 *branchcut wrote:*   

> Hi all,
> 
> I'm very new to cron so I don't know the pitfalls or "best practices" of using this tool. I'm using vixie-cron.
> 
> I'd like to run emerge --sync at 3:30 am every morning. Not hard, I guess I just add this line to my crontab:
> ...

 

Yes run that as root. So as ROOT, do a crontab -e and add that entry, but you should probably add all this verbiage to the command:

```
30      3       *       *       *       /usr/bin/emerge --sync > /dev/null  2>&1
```

----------

## bumpus

Better is to put a script that will run the emerge --sync command in /etc/cron.daily/. That location will cause the command to be run sometime overnight during a time when the system feels it is not otherwise busy rather than at a precise time each day.

----------

