How to delay a systemd unit until network is ready?
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I've switched from cron to systemd-cron with my Debian unstable system, but now the daily "cron-job" often fails, because it runs mixmaster which fetches it's database from the internet and if the cron-daily.timer gets triggered before the network is up, after wake-up from suspend to RAM, mixmaster can't reach the server.
Apr 24 11:02:23 run-parts[13608]: /usr/bin/mixmaster-update: Get failed for http://www.noreply.org/echolot/pgp-all.asc (500 Can't connect to www.noreply.org:80)
Apr 24 11:02:23 run-parts[13608]: Downloading of mlist and/or mixring failed (do you need a proxy?). Aborting.
Apr 24 11:02:23 su[13809]: pam_unix(su:session): session closed for user mixmaster
Apr 24 11:02:23 run-parts[13608]: run-parts: /etc/cron.daily/mixmaster exited with return code 22
Is it possible to delay the timer until the network is up and running?
networking systemd cron
add a comment |
up vote
4
down vote
favorite
I've switched from cron to systemd-cron with my Debian unstable system, but now the daily "cron-job" often fails, because it runs mixmaster which fetches it's database from the internet and if the cron-daily.timer gets triggered before the network is up, after wake-up from suspend to RAM, mixmaster can't reach the server.
Apr 24 11:02:23 run-parts[13608]: /usr/bin/mixmaster-update: Get failed for http://www.noreply.org/echolot/pgp-all.asc (500 Can't connect to www.noreply.org:80)
Apr 24 11:02:23 run-parts[13608]: Downloading of mlist and/or mixring failed (do you need a proxy?). Aborting.
Apr 24 11:02:23 su[13809]: pam_unix(su:session): session closed for user mixmaster
Apr 24 11:02:23 run-parts[13608]: run-parts: /etc/cron.daily/mixmaster exited with return code 22
Is it possible to delay the timer until the network is up and running?
networking systemd cron
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I've switched from cron to systemd-cron with my Debian unstable system, but now the daily "cron-job" often fails, because it runs mixmaster which fetches it's database from the internet and if the cron-daily.timer gets triggered before the network is up, after wake-up from suspend to RAM, mixmaster can't reach the server.
Apr 24 11:02:23 run-parts[13608]: /usr/bin/mixmaster-update: Get failed for http://www.noreply.org/echolot/pgp-all.asc (500 Can't connect to www.noreply.org:80)
Apr 24 11:02:23 run-parts[13608]: Downloading of mlist and/or mixring failed (do you need a proxy?). Aborting.
Apr 24 11:02:23 su[13809]: pam_unix(su:session): session closed for user mixmaster
Apr 24 11:02:23 run-parts[13608]: run-parts: /etc/cron.daily/mixmaster exited with return code 22
Is it possible to delay the timer until the network is up and running?
networking systemd cron
I've switched from cron to systemd-cron with my Debian unstable system, but now the daily "cron-job" often fails, because it runs mixmaster which fetches it's database from the internet and if the cron-daily.timer gets triggered before the network is up, after wake-up from suspend to RAM, mixmaster can't reach the server.
Apr 24 11:02:23 run-parts[13608]: /usr/bin/mixmaster-update: Get failed for http://www.noreply.org/echolot/pgp-all.asc (500 Can't connect to www.noreply.org:80)
Apr 24 11:02:23 run-parts[13608]: Downloading of mlist and/or mixring failed (do you need a proxy?). Aborting.
Apr 24 11:02:23 su[13809]: pam_unix(su:session): session closed for user mixmaster
Apr 24 11:02:23 run-parts[13608]: run-parts: /etc/cron.daily/mixmaster exited with return code 22
Is it possible to delay the timer until the network is up and running?
networking systemd cron
networking systemd cron
asked Apr 24 '17 at 14:17
jo-so
3113
3113
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
It might be worth using systemd's timers rather than cron. You should then be able to specify in the unit what it depends on.
https://wiki.archlinux.org/index.php/Systemd#Handling_dependencies
The systemd-cron package in Debian are the systemd timers to replace sysv-cron. packages.debian.org/sid/systemd-cron
– jo-so
Apr 25 '17 at 17:32
add a comment |
up vote
2
down vote
Use systemd timers instead of cron.
Then in your systemd-unit, you can specify After=network-online.target and Wants=network-online.target
.
1
This doesn't help, because the target becomes active after boot, but remains untouched when the network goes down due to suspend to RAM e.g.
– jo-so
Apr 25 '17 at 17:39
If all else fails, you can add a "sleep" statement to the script you run, to have it wait for a period before attempting to connect, likeExecStartPre=/bin/sleep 60
– Mark Stosberg
Apr 25 '17 at 18:25
add a comment |
up vote
0
down vote
In my setup the cron job is run every ten minutes, but quits if there is no internet connection, by a connectivity test such as
nc -zw3 github.com 22 || exit 0
When there is finally an internet connection, then, once a day, an anacron job is run.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
It might be worth using systemd's timers rather than cron. You should then be able to specify in the unit what it depends on.
https://wiki.archlinux.org/index.php/Systemd#Handling_dependencies
The systemd-cron package in Debian are the systemd timers to replace sysv-cron. packages.debian.org/sid/systemd-cron
– jo-so
Apr 25 '17 at 17:32
add a comment |
up vote
2
down vote
It might be worth using systemd's timers rather than cron. You should then be able to specify in the unit what it depends on.
https://wiki.archlinux.org/index.php/Systemd#Handling_dependencies
The systemd-cron package in Debian are the systemd timers to replace sysv-cron. packages.debian.org/sid/systemd-cron
– jo-so
Apr 25 '17 at 17:32
add a comment |
up vote
2
down vote
up vote
2
down vote
It might be worth using systemd's timers rather than cron. You should then be able to specify in the unit what it depends on.
https://wiki.archlinux.org/index.php/Systemd#Handling_dependencies
It might be worth using systemd's timers rather than cron. You should then be able to specify in the unit what it depends on.
https://wiki.archlinux.org/index.php/Systemd#Handling_dependencies
answered Apr 24 '17 at 14:37
Jonathan Hodgson
9213
9213
The systemd-cron package in Debian are the systemd timers to replace sysv-cron. packages.debian.org/sid/systemd-cron
– jo-so
Apr 25 '17 at 17:32
add a comment |
The systemd-cron package in Debian are the systemd timers to replace sysv-cron. packages.debian.org/sid/systemd-cron
– jo-so
Apr 25 '17 at 17:32
The systemd-cron package in Debian are the systemd timers to replace sysv-cron. packages.debian.org/sid/systemd-cron
– jo-so
Apr 25 '17 at 17:32
The systemd-cron package in Debian are the systemd timers to replace sysv-cron. packages.debian.org/sid/systemd-cron
– jo-so
Apr 25 '17 at 17:32
add a comment |
up vote
2
down vote
Use systemd timers instead of cron.
Then in your systemd-unit, you can specify After=network-online.target and Wants=network-online.target
.
1
This doesn't help, because the target becomes active after boot, but remains untouched when the network goes down due to suspend to RAM e.g.
– jo-so
Apr 25 '17 at 17:39
If all else fails, you can add a "sleep" statement to the script you run, to have it wait for a period before attempting to connect, likeExecStartPre=/bin/sleep 60
– Mark Stosberg
Apr 25 '17 at 18:25
add a comment |
up vote
2
down vote
Use systemd timers instead of cron.
Then in your systemd-unit, you can specify After=network-online.target and Wants=network-online.target
.
1
This doesn't help, because the target becomes active after boot, but remains untouched when the network goes down due to suspend to RAM e.g.
– jo-so
Apr 25 '17 at 17:39
If all else fails, you can add a "sleep" statement to the script you run, to have it wait for a period before attempting to connect, likeExecStartPre=/bin/sleep 60
– Mark Stosberg
Apr 25 '17 at 18:25
add a comment |
up vote
2
down vote
up vote
2
down vote
Use systemd timers instead of cron.
Then in your systemd-unit, you can specify After=network-online.target and Wants=network-online.target
.
Use systemd timers instead of cron.
Then in your systemd-unit, you can specify After=network-online.target and Wants=network-online.target
.
answered Apr 24 '17 at 18:14
Mark Stosberg
3,7711125
3,7711125
1
This doesn't help, because the target becomes active after boot, but remains untouched when the network goes down due to suspend to RAM e.g.
– jo-so
Apr 25 '17 at 17:39
If all else fails, you can add a "sleep" statement to the script you run, to have it wait for a period before attempting to connect, likeExecStartPre=/bin/sleep 60
– Mark Stosberg
Apr 25 '17 at 18:25
add a comment |
1
This doesn't help, because the target becomes active after boot, but remains untouched when the network goes down due to suspend to RAM e.g.
– jo-so
Apr 25 '17 at 17:39
If all else fails, you can add a "sleep" statement to the script you run, to have it wait for a period before attempting to connect, likeExecStartPre=/bin/sleep 60
– Mark Stosberg
Apr 25 '17 at 18:25
1
1
This doesn't help, because the target becomes active after boot, but remains untouched when the network goes down due to suspend to RAM e.g.
– jo-so
Apr 25 '17 at 17:39
This doesn't help, because the target becomes active after boot, but remains untouched when the network goes down due to suspend to RAM e.g.
– jo-so
Apr 25 '17 at 17:39
If all else fails, you can add a "sleep" statement to the script you run, to have it wait for a period before attempting to connect, like
ExecStartPre=/bin/sleep 60
– Mark Stosberg
Apr 25 '17 at 18:25
If all else fails, you can add a "sleep" statement to the script you run, to have it wait for a period before attempting to connect, like
ExecStartPre=/bin/sleep 60
– Mark Stosberg
Apr 25 '17 at 18:25
add a comment |
up vote
0
down vote
In my setup the cron job is run every ten minutes, but quits if there is no internet connection, by a connectivity test such as
nc -zw3 github.com 22 || exit 0
When there is finally an internet connection, then, once a day, an anacron job is run.
add a comment |
up vote
0
down vote
In my setup the cron job is run every ten minutes, but quits if there is no internet connection, by a connectivity test such as
nc -zw3 github.com 22 || exit 0
When there is finally an internet connection, then, once a day, an anacron job is run.
add a comment |
up vote
0
down vote
up vote
0
down vote
In my setup the cron job is run every ten minutes, but quits if there is no internet connection, by a connectivity test such as
nc -zw3 github.com 22 || exit 0
When there is finally an internet connection, then, once a day, an anacron job is run.
In my setup the cron job is run every ten minutes, but quits if there is no internet connection, by a connectivity test such as
nc -zw3 github.com 22 || exit 0
When there is finally an internet connection, then, once a day, an anacron job is run.
answered Nov 21 at 15:28
Enno
11113
11113
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f360984%2fhow-to-delay-a-systemd-unit-until-network-is-ready%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown