I'm having an issue where I have a bunch of systemd timers set to run on a schedule to do various backup related tasks. They run successfully at the appointed time. However they also run when the system boots up, which I want to avoid. For example I have a remote rsync that takes a couple of hours to complete, and it needs to only run once at night, not upon reboot.
Here's an example timer:
[Unit] Description=Run Remote rsync Requires=remote-backup.service [Timer] OnCalendar=*-*-* 4:00:00 RandomizedDelaySec=1h Persistent=false [Install] WantedBy=timers.target
And here's the service it runs:
[Unit] Description=Remote backup After=zfs.target network-online.target OnFailure=status-email-root@%n.service [Service] Type=oneshot ExecStartPre=/path/to/pre-backup script ExecStart=/path/to/backup-script ExecStartPost=/path/to/post-backup script
(the pre and post backup scripts ping a health check URL So that I get reports of success/failure/etc.)
The issue is that it's supposed to run only at 4am but if I reboot it will try to run on startup. I've tried changing
Persistent to false with no effect. I'd like to keep it as true, because if the backup truly failed or didn't run, I'd like to rerun it, but not run it every damn time!
I also tried removing the
WantedBy but that just made the thing never run, and I also tried changing the
Type on the service without success.
If anyone has any insight I'd really appreciate it. Thanks!