You are not logged in.
Hi,
I am trying to create a systemd timer that runs its associated service every 10 hours of system activity. Downtime should be ignored and the timer should be persistent over reboots.
Example:
The system runs 3 hours on Monday, 6 hours on Tuesday and 12 hours on Wednesday
The timer should trigger on Wednesday after running for 1 hour and then again on the same day after the next 10 hours of active runtime has passed
The problem I have is that there is no persistent setting other then for OnCalendar timers.
I am currently using this:
[Unit]
Description=Execute test service
Requires=mytest.service
[Timer]
OnUnitActiveSec=10h
[Install]
WantedBy=timers.target
But this timer actually resets at every boot and starts every day.
How do I keep a persistent timer that actually depends on the time the unit was active and persists over reboots?
Offline
Hello for your first post.
You can keep the active time in a file running the uptime command before shutting down.
Then you have to write a script to use this to obtain what you want.
It can be a good exercise, when something doesn't exist do it yourself !
Offline