Score:0

Triggering a systemd service on every boot and at the top of every subsequent hour

hn flag

Hi I am trying to configure both systemd service and timer files to run a shell script (capturing footage) both on boot and at the start of every subsequent hour.

The service and shell script run as intended on the hour but only runs on boot if the service has not been trigger in the current hour (I believe due to Persistent=True).

While this is mostly what I need, if I reboot (expectedly or not) after this initial on boot start, the service doesn't start again until the next hour start; as I need to be capturing cam footage constantly this is not ideal.

Would really appreciate some help seeing what I am missing but also opinions on whether moving to using a service which would restart once the script finished executing (script handles filming length itself) with Restart=on-failure changed to Restart=always being a better solution?

I am only enabling the timer file with: sudo systemctl enable start_capture.timer

.service file:

[Unit]
Description=executes camera capture script
StartLimitIntervalSec=0

[Service]
Type=simple
ExecStart=/usr/bin/bash path/start_capture.sh
Restart=on-failure
RestartSec=2

.timer file:

[Unit]
Description=schedules video capture service
After=multi-user.target

[Timer]
OnCalendar=hourly
Persistent=True
Unit=start_capture.service

[Install]
WantedBy=timers.target

Edit: I am running this on 64-bit Bullseye on a model 3b but maybe using final code on model 4.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.