定时任务
#mirror web*/5 * * * * cd /mirror && git pull#mysql mirror0 */3 * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7/ /mirror/mysql/yum/mysql-connectors-community-el7/ > /dev/null 2>&1;0 */3 * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7/ /mirror/mysql/yum/mysql-tools-community-el7/ > /dev/null 2>&1;0 */3 * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/ /mirror/mysql/yum/mysql57-community-el7/ > /dev/null 2>&1;0 */3 * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/ /mirror/mysql/yum/mysql80-community-el7/ > /dev/null 2>&1;#centos mirror0 */4 * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/centos/ /mirror/centos/ > /dev/null 2>&1;#epel mirror0 */4 * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/epel/ /mirror/epel/ > /dev/null 2>&1;#ubuntu-mirror0 */4 * * * bash /srv/sh/apt-mirror.sh#zabbix-mirror0 */6 * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.4/ /mirror/zabbix/3.4/ > /dev/null 2>&1;0 */6 * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/ /mirror/zabbix/4.0/ > /dev/null 2>&1;
定时任务脚本
#!/bin/bashkillall -9 apt-mirrorkillall -9 wgetrm -rf /mirror/apt-mirror/var/apt-mirror.lock#同步/usr/sbin/apt-mirror > /srv/logs/apt-mirror/apt-mirror-`date +%Y-%m-%d-%H:%M:%S`.logsleep 10s#自动清理sh /mirror/apt-mirror/var/clean.sh#删除一周前的日志find /srv/logs/apt-mirror/*.log -type f -mtime +2 -exec rm {} \;
配置同步内容
# apt-mirror configuration file## The default configuration options (uncomment and change to override)set base_path /mirror/apt-mirrorset mirror_path $base_path/mirrorset skel_path $base_path/skelset var_path $base_path/var## set defaultarchset nthreads 20set _tilde 0set defaultarch amd64## mirror sources#ubuntu14.04 LTSdeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse#ubuntu16.04 LTSdeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse#ubuntu18.04 LTSdeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse## Cleaner configuration example# set cleanscript $var_path/clean.sh# Cleaning sectionclean https://mirrors.tuna.tsinghua.edu.cn/ubuntu