You are not logged in.
Pages: 1
Hey all!
So, I have a laptop that I want a daily backup script to run. The script works great, but I'm wondering if there is a way to make it only run when WiFi is connected.
What happens is that I close my laptop lid to go to sleep. When I open the lid, the backup timer kicks off and immediately fails because the WiFi takes a few seconds to connect. I've semi-fixed this by adding in a "Restart on-failure"... so it will try again a few minutes later. I was wondering if anyone knows a cleaner approach that will actually wait for an active wifi connection.
My laptop runs KDE with NetworkManager... not sure if those provide any tools to help....
This is what I have right now:
backup.timer
[Unit]
Description=Daily Backup Timer
[Timer]
OnCalendar=daily
[Install]
WantedBy=timers.targetbackup.service
[Unit]
Description=Daily Backup
StartLimitInterval=2000
StartLimitBurst=5
[Service]
Type=oneshot
Restart=on-failure
RestartSec=300
ExecStart=/bin/bash /root/backup.shOffline
Offline
Theoretically nice. Likely won't do in practice…
https://bbs.archlinux.org/viewtopic.php … 3#p1948193
If backup.sh requries some network condition (more likely access to some domain/IP) you could timeout there?
counter=6; while ((--counter > 0)) && ! ping -W5 -c1 example.com; do sleep 5; doneOnline
Pages: 1