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