From 0cca19d94850fc683bd2573405cc7364f2459a11 Mon Sep 17 00:00:00 2001 From: Jeena Date: Thu, 14 Aug 2025 19:59:24 +0900 Subject: [PATCH] Add systemd timer --- README.md | 11 +++++++++++ systemd/kidsnote.service | 9 +++++++++ systemd/kidsnote.timer | 9 +++++++++ 3 files changed, 29 insertions(+) create mode 100644 systemd/kidsnote.service create mode 100644 systemd/kidsnote.timer diff --git a/README.md b/README.md index a967959..2322f10 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,17 @@ pipenv install 4. Run `pipenv run ./get_report.py` to get the report, it stores it in a file report.json 5. Run `pipenv run ./report_json_down.py` to download all the reports and pictures +## Run automatically with a systemd timer + +This will run the script every day at midnight or once you wake up your computer: + +1. `cp systemd/kidsnote.service ~/.config/systemd/user/` +2. `cp systemd/kidsnote.timer ~/.config/systemd/user/` +3. `systemctl --user daemon-reload` +4. `systemctl --user enable --now kidsnote.timer` + +It assumes you already set up the .env file. + ## Why username and password? In the old script you had to get the report manually from the browser. diff --git a/systemd/kidsnote.service b/systemd/kidsnote.service new file mode 100644 index 0000000..73b75f8 --- /dev/null +++ b/systemd/kidsnote.service @@ -0,0 +1,9 @@ +[Unit] +Description=Download Kidsnote reports and JSON +Wants=kidsnote.timer + +[Service] +Type=oneshot +WorkingDirectory=/home/jeena/Projects/kidsnote +ExecStart=/usr/bin/pipenv run ./get_report.py +ExecStart=/usr/bin/pipenv run ./report_json_down.py diff --git a/systemd/kidsnote.timer b/systemd/kidsnote.timer new file mode 100644 index 0000000..fa88c58 --- /dev/null +++ b/systemd/kidsnote.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run Kidsnote download script once per day + +[Timer] +OnCalendar=daily +Persistent=true + +[Install] +WantedBy=timers.target