编写自己的systemd服务

nano -w /usr/lib/systemd/system/archlinux-update.timer

[Unit]
Description=rsync the resposity of archlinx daily

[Timer]
OnCalendar=*-*-* *:30:00
AccuracySec=4h
Persistent=true

[Install]
WantedBy=timers.target

修改后重新加载服务

systemctl daemon-reload

nano -w /usr/lib/systemd/system/archlinux-update.service
[Unit]
Description=rsync the resposity of archlinx daily

[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/data/sync.sh

 

sync.sh为自动同步archlinux的源,注意红色部分的-, 没有的话无法正常运行

#!/bin/bash

/usr/bin/rsync -rtlvH –delete-after –delay-updates –safe-links –max-delete=500000 rsync://mirrors.ustc.edu.cn/archlinux/ /data/archlinux/

chown -R http.http /data/archlinux

不要忘记启动定时器呀…
systemctl enable archlinux-update.timer

关于Zeno Chen

本人涉及的领域较多,杂而不精 程序设计语言: Perl, Java, PHP, Python; 数据库系统: MySQL,Oracle; 偶尔做做电路板的开发,主攻STM32单片机
此条目发表在Linux分类目录。将固定链接加入收藏夹。

发表回复