Skip to content

Instantly share code, notes, and snippets.

@afiestas
Last active July 3, 2022 20:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afiestas/be5b4254de13991b6b6d914ad5f61b59 to your computer and use it in GitHub Desktop.
Save afiestas/be5b4254de13991b6b6d914ad5f61b59 to your computer and use it in GitHub Desktop.
systemd timer for ddns/dyndns/dynamic dns or any other http request
# /etc/systemd/system/ddns.service
[Unit]
Description=Updates ddns via curl
[Service]
Type=oneshot
ExecStart=/usr/bin/curl "https://your request goes here"
#You might have or want to change user/group
#User=nobody
#Group=nogroup
#Or just use a dynamically generated one
DynamicUser=yes
PrivateTmp=yes
ProtectSystem=strict
ProtectHome=true
MemoryDenyWriteExecute=yes
PrivateDevices=true
PrivateUsers=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictNamespaces=true
LockPersonality=true
RestrictRealtime=true
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/ddns.timer
# systemctl enable ddns.timer
# systemctl start ddns.timer
[Unit]
Description=Update a ddns provider
[Timer]
OnBootSec=1s
OnUnitActiveSec=30s
[Install]
WantedBy=timers.target
@eliasp
Copy link

eliasp commented Dec 27, 2017

For a scenario like this, you might simply want to use DynamicUser=yes instead of User=/Group= (requires >=systemd-232).

@afiestas
Copy link
Author

Added!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment