Skip to content

Instantly share code, notes, and snippets.

@grchen grchen/archtimer.md
Last active May 7, 2017

Embed
What would you like to do?
arch linux增加定式任务

在 Arch Linux 上,我们通过 systemd 来自动执行证书续期任务。


$ sudo vim /etc/systemd/system/letsencrypt.service
[Unit]
Description=Let's Encrypt renewal

[Service]
Type=oneshot  
ExecStart=/usr/bin/certbot renew --quiet --agree-tos  
ExecStartPost=/bin/systemctl reload nginx.service  
然后增加一个 systemd timer 来触发这个服务:

$ sudo vim /etc/systemd/system/letsencrypt.timer
[Unit]
Description=Monthly renewal of Let's Encrypt's certificates

[Timer]
OnCalendar=daily  
Persistent=true

[Install]
WantedBy=timers.target  
启用服务,开启 timer:

$ sudo systemctl enable letsencrypt.timer
$ sudo systemctl start letsencrypt.timer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.