autorestic icon indicating copy to clipboard operation
autorestic copied to clipboard

Add option to wait for the lock to unlock

Open dotboris opened this issue 10 months ago • 0 comments

Is your feature request related to a problem? Please describe.

I have multiple cron jobs on my system that interact with autorestic and sometimes they line up and one of them crashes because the lock is already taken. Specifically, I have the following:

  • Every 5 minutes, I run autorestic cron
  • Every month, I run autorestic exec --all -- check

This month, they happened to run at the same time. autorestic cron ran and autorestic exec --all -- check crashed because the lock was already taken.

Describe the solution you'd like

I'd like there to be a CLI option for all autorestic commands that makes it wait for the lock instead of crashing right away. This would look something like this:

autorestic cron --wait-for-lock PT5M # 5 minutes is ISO 8601 format
autorestic exec --wait-for-lock PT5M --all -- check

I think that it would probably be a good idea to have an option to control how often autorestic checks to see if the lock has been released.

I'm not sure if this is a good idea but it might be helpful to be able to configure this behavior in the config file.

dotboris avatar May 01 '25 20:05 dotboris