8.8. Automating Synchronization

Manually synchronizing the RHN Satellite Server repository with Red Hat Network can be an arduous task. In addition, staff levels tend to be highest at peak usage times. For this reason, Red Hat encourages you to automate synchronization in late evening or early morning to better balance load and ensure quick synchronization. Further, Red Hat strongly recommends synchronization occur randomly for best performance.

This automation can be set easily by the addition of a simple cron job. To do this, edit the crontab as root:

crontab -e

This opens the crontab in a text editor, by default Vi. Another editor can be used by first changing the EDITOR variable, like so: export EDITOR=gedit.

Once opened, use the first five fields (minute, hour, day, month, and weekday) to schedule the synchronization. Remember, hours use military time. Edit the crontab to include random synchronization, like so:

0 1 * * * perl -le 'sleep rand 9000' && satellite-sync --email >/dev/null 2>/dev/null

This particular job will run randomly between 1:00 a.m. and 3:30 a.m. system time each night and redirect stdout and stderr from cron to prevent duplicating the more easily read message from satellite-sync. Options other than --email can also be included. Refer to Section 6.1.2 Import/Sync Options for the full list of options. Once you exit from the editor, the modified crontab is installed immediately.