[systemd-devel] anacron timer for backup job to depend on network-online.target

Andrei Borzenkov arvidjaar at gmail.com
Sun Mar 1 19:26:21 PST 2015

В Sun, 01 Mar 2015 22:13:11 +0100
Thomas Koch <thomas at koch.ro> пишет:

> meta: is it ok to ask user questions on this list?
> Hi,
> I want my backup job to be triggered only, if my laptop is online. I've a 
> service file and a timer file. Should I add a Wants= and After= dependency on 
> network-online.target? To which file?

No, network-online.target is relevant only during boot and even then it
is best effort only. The simplest solution would be to add check of
"online state" to your backup script and gracefully fail if system is
not online.

> What is the effect, if the laptop is offline for a longer period? Will the backup 
> jobs accumulate? Will a backup job trigger immediately when a connection is 
> established and the job is overdue?

systemd does not know anything about network online state. What
software are you using to configure network? 

> Regards, Thomas Koch
> /etc/systemd/system/mybackup.service:
> [Unit]
> Description=run obnam backup
> [Service]
> Type=simple
> ExecStart=obnam backup
> /etc/systemd/system/mybackup.timer:
> [Unit]
> Description=schedules obnam backup
> [Timer]
> OnBootSec=5min
> OnUnitActiveSec=8h
> Unit=mybackup.service
> Persistent=true
> [Install]
> WantedBy=multi-user.target
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel

More information about the systemd-devel mailing list