What is the most efficient way to run a task every X hours of runtime, accumulated over all power-ons?
0
votes
0
answers
106
views
Let us assume that I have a machine which wakes up at 7:00, does some work, usually for 15 minutes, but sometimes for days (e.g., experiment supervision), and after the works is done, it powers itself off.
I want to run a certain analysis tool at each 10 hours of runtime. This may happen to be every 40 days if the machine only spends 15 minutes every day, but it may need to run twice a day if there is a lot of work for the machine to do.
How would I achieve this?
What comes immediately to mind is to dump "uptime" into a log file by a bash loop, and read it, still, every minute, to sum the uptimes since the last analysis tool run. When the desired time comes, inhibit shutdown (how would I do that?), do the analysis, and shutdown manually.
This would work, but is (1) very I/O intensive, (2) hacky, and (3) failing if analysis itself takes more than 10 hours, which may happen.
Is there a better way?
Asked by Vladimir Nikishkin
(31 rep)
Dec 29, 2021, 06:09 AM