This article explains how to schedule your mirroring using cron, a time-based job scheduler.
Please follow either User Level or System Level section.
NOTE: If you already have other cron jobs running from your System level cron tab, it is recommended to follow User Level section.
User Level
1. Switch to the Repository administrator account:
sudo su - anaconda-server
Replace anaconda-server with your user name if it is different.
2. Run the following command to open your crontab file:
crontab -e
3. Add the following line:
[cron expression] mirroring-cmd
Replace [cron expression] and mirroring-cmdwith your expression and command.
Examples:
-
0 0 1 * * /home/anaconda-server/repo/bin/anaconda-server-sync-conda --mirror-config /home/anaconda-server/repo/etc/anaconda-server/mirrors/conda-forge.yaml --account=conda-forge >> /home/anaconda-server/mirrors.log
This command will mirror the conda-forge channel once a month at 12 am of the first day of the month.
-
01 08 1 * * /home/anaconda-server/repo/bin/anaconda-server-sync-conda --mirror-config /home/anaconda-server/repo/etc/anaconda-server/mirrors/anaconda.yaml --account=anaconda >> /home/anaconda-server/mirrors.log
This command will mirror the anaconda channel once a month at 08:01 am of the first day of the month.
NOTE: Path to a file may be different in your system, you could find it using locate command:
Example:
locate anaconda-server-sync-conda
You can also add all of the mirroring commands in a separate bash script, mirror.sh :
/home/anaconda-server/repo/bin/anaconda-server-sync-conda --mirror-config /home/anaconda-server/repo/etc/anaconda-server/mirrors/conda-forge.yaml --account=conda-forge
/home/anaconda-server/repo/bin/anaconda-server-sync-conda --mirror-config /home/anaconda-server/repo/etc/anaconda-server/mirrors/anaconda.yaml --account=anaconda
And then add the script to crontab file:
0 0 1 * * /home/anaconda-server/mirrors.sh > /home/anaconda-server/mirrors.log
4. Run the following command to see your crontab file contents.
crontab -l
Or go to root:
sudo su -
You will find it here: /var/spool/cron/anaconda-server
System Level
You could also add the mirror commands in the system wide crontab file. The only advantage of adding in the system wide crontab is there is an environment variable in crontab file, MAILTO . If you add your email in that field, you will get notifications each time when the cronjob runs.
1. Go to root:
sudo su -
2. Run:
vi /etc/crontab
3. Enter the command in crontab file :
01 08 1 * * /home/anaconda-server/repo/bin/anaconda-server-sync-conda --mirror-config /home/anaconda-server/repo/etc/anaconda-server/mirrors/anaconda.yaml --account=anaconda >> /home/anaconda-server/mirrors.log
NOTE: Path to a file may be different in your system, you could find it using locate command.
Example:
locate anaconda-server-sync-conda
If you have mirror commands in the bash script, enter:
0 0 1 * * anaconda-server /home/anaconda-server/mirrors.sh > /home/anaconda-server/mirrors.log
Since it is system wide, you need to mention your username. Replace anaconda-server with your user name if it is different. Also, add your email in MAILTO .
You can also use other files like crontab.monthly , crontab.weekly .