I am just wondering about synchronization of systemd timers / related units. I have a backup script running hourly / daily / weekly. I use timers with
OnCalendar=... options set to launch the units.
The problem is that systemd launches multiple units at once if units were missed due to the machine being turned off. Since this could cause problems the script uses a lockfile to make sure there is only one instance running at any time: If the lockfile is present while executing the script fails and no backup is performed. I was just wondering if there is a way in systemd to ensure that jobs are not run in parallel (I seem to remember that this was possible in anacron) to avoid this situation.
Edit: The unit file (
rsnapshot@.service) looks like this:
[Unit] Description=rsnapshot (%I) backup [Service] Type=oneshot Nice=19 IOSchedulingClass=3 ExecStart=/usr/bin/rsnapshot %I
An example timer is here (
[Unit] Description=rsnapshot hourly backup [Timer] OnCalendar=hourly Persistent=true Unitemail@example.com [Install] WantedBy=timers.target
A running service looks like this (
systemctl status firstname.lastname@example.org):
● email@example.com - rsnapshot (daily) backup Loaded: loaded (/etc/systemd/system/rsnapshot@.service; static; vendor preset: disabled) Active: activating (start) since Do 2015-07-23 21:42:03 CEST; 1min 2s ago Main PID: 527 (rsnapshot) CGroup: /firstname.lastname@example.org ├─527 /usr/bin/perl -w /usr/bin/rsnapshot daily └─560 /bin/rm -rf /media/large_store/backup/bigbox/daily.6/