From f5644e98f93c212142fce81ed9a887f5cc53d628 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 17 Oct 2017 01:49:33 +0900 Subject: [PATCH] Created Using systemd units instead of cron (markdown) --- Using-systemd-units-instead-of-cron.md | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Using-systemd-units-instead-of-cron.md diff --git a/Using-systemd-units-instead-of-cron.md b/Using-systemd-units-instead-of-cron.md new file mode 100644 index 0000000..7a90b6d --- /dev/null +++ b/Using-systemd-units-instead-of-cron.md @@ -0,0 +1,37 @@ +**1. Create a systemd unit for acme.sh:** + +`/etc/systemd/system/acme_letsencrypt.service` +``` +[Unit] +Description=Renew Let's Encrypt certificates using acme.sh +After=network-online.target + +[Service] +Type=oneshot +ExecStart=/path/to/acme.sh +``` + +**2. Test that it works before creating the timer:** +``` +sudo systemctl daemon-reload +sudo systemctl start acme_letsencrypt --now +``` + +**3. Create systemd timer unit for the service above:** + +`/etc/systemd/system/acme_letsencrypt.timer` +``` +[Unit] +Description=Daily renewal of Let's Encrypt's certificates + +[Timer] +OnCalendar=daily +RandomizedDelaySec=1h +Persistent=true + +[Install] +WantedBy=timers.target +``` + +**4. Enable timer:** +`sudo systemctl enable acme_letsencrypt.timer` \ No newline at end of file