On 01/10/2021 22:54, Canek Peláez Valdés wrote:
On Fri, Oct 1, 2021 at 3:37 PM antlists <[email protected] <mailto:[email protected]>> wrote:



I think it would be much simpler to have a Type=oneshot service at boot, and the Exec= line to call a script. You can store the timestamp of the last time it was called someplace in the filesystem (say, /var/lib/my-script or something), and if the timestamp doesn't exists or is older than one week, the scripts executes lvm snapshot and updates the timestamp; otherwise it ends without doing anything.

Ouch. Dunno if that would work. Bear in mind I'm running this BEFORE fstab, so / is read-only ...

The timer units are very similar to cron, and I believe what you want cannot be done with cron either; you need special logic and state ("I'm booting AND haven't run this in at least a week"), so a script is necessary (I think). Luckly, systemd allows you to smartly manage your scripts and impose dependencies on them (you need /var in my example, and you can set it to run before starting X).

I will have to see if the timer can set up the oneshot service, and if it really is one shot per activation ...

Cheers,
Wol

Reply via email to