From 7143aa3a31d113c97a9743890fb8d38f176d47e8 Mon Sep 17 00:00:00 2001 From: netravnen <1938389+netravnen@users.noreply.github.com> Date: Fri, 30 Jun 2023 19:20:32 +0200 Subject: [PATCH] Add systemd timer and modify cron instructions 1. Add information concerning a system timer 2. Modify the existing cron instructions to use cron.weekly instead of a custom crontab timer --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 22510ae..eace485 100644 --- a/README.md +++ b/README.md @@ -200,22 +200,58 @@ cd /opt/ sudo git clone https://github.com/anudeepND/whitelist.git ``` -Make the script to run the script at 1AM on the last day of the week +Make the script to run the script once a week ```Shell -sudo nano /etc/crontab +sudo nano /etc/cron.weekly/whitelist ``` -Add this line at the end of the file: +Add this to the file: -```Text -0 1 * * */7 root /opt/whitelist/scripts/whitelist.py +```bash +#! /usr/bin/env bash + +python3 /opt/whitelist/scripts/whitelist.py ``` -CTRL + X then Y and Enter +### systemd + +Make the timer to run the script once a week ```Shell -sudo python3 whitelist/scripts/whitelist.py +sudo nano /etc/systemd/system/whitelist.timer +``` + +Add this to the file: + +```conf +[Unit] +Description=Timer for reloading Pi-Hole Whitelist + +[Timer] +OnCalendar=Sun *-*-* 01:00:00 +AccuracySec=1h +RandomizedDelaySec=6h + +[Install] +WantedBy=timers.target +``` + +Make the script to run the script + +```shell +sudo nano /etc/systemd/system/whitelist.service +``` + +Add this to the file: + +```conf +[Unit] +Description=Pi-Hole Whitelist update + +[Service] +Type=oneshot +ExecStart=/usr/bin/python3 /opt/whitelist/scripts/whitelist.py ``` ## How do I determine an ad domain?