Skip to content

Instantly share code, notes, and snippets.

@mailinglists35
Forked from mosquito/pingd.service
Last active October 10, 2018 17:06
Show Gist options
  • Save mailinglists35/11a6c3fbeac73bf0ca469217bcfc0b7c to your computer and use it in GitHub Desktop.
Save mailinglists35/11a6c3fbeac73bf0ca469217bcfc0b7c to your computer and use it in GitHub Desktop.
Systemd ping daemon
[root@stage ~]# cat /etc/systemd/system/ping@.service
[Unit]
Description=One time ping check of host %I
After=network.target
[Service]
Type=forking #forking makes the unit stay in starting state until ping finishes. oneshot does not work with RemainAfterExit, while type simple makes the unit started as soon as ping starts, which is something we DON'T want
Restart=on-failure
ExecStart=/bin/ping -q -c 5 %i
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
#
systemctl enable ping@remotehost
#
systemctl edit --full some-service-that-needs-external-connectivity
After=ping@remotehost
Requires=ping@remotehost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment