Create a crontab script with curl

0

Trying to set a cronjob to use with curl. Want to update IP on noip.com. The command below gets the IP from noip.com but does not update it with my servers ip. I mean: when the IP is not updated then I get the old one:

curl -X GET 'https://dynupdate.no-ip.com/nic/update' --header "Authorization: Basic $(base64 <<< $xxxxxxx:$xxxxxx)" -d "hostname=$xxxxx.ddns.net"

this command below poduces error sh: GET: command not found

ExecStart=/usr/bin/curl-X GET 'https://dynupdate.no-ip.com/nic/update' --header "Authorization: Basic <$xxxxx:$xxxxx>" -d 'hostname=<hostname>.xxxxxx.ddns.net'

Need help for an appropriate script

ddinc

Posted 2018-12-04T14:19:02.403

Reputation: 1

Why does the second command have an ExecStart= in front of it? – user1686 – 2018-12-04T14:38:22.160

Actually I have copied from a forum :) don't know its accuracy – ddinc – 2018-12-04T14:58:48.420

Answers

0

On a modern Linux system, you do not want to use crontab, but systemd timers.

Create the file /etc/systemd/system/updateip.service with the following content:

[Unit]
Description=Update IP

[Service]
Type=oneshot
ExecStart=/usr/bin/curl -X GET 'https://dynupdate.no-ip.com/nic/update' --header "Authorization: Basic <$xxxxx:$xxxxx>" -d 'hostname=<hostname>.xxxxxx.ddns.net'

Now you add a timer in /etc/systemd/system/updateip.timer with the following contents, to run every 10 minutes:

[Unit]
Description=Update IP every 10 minutes

[Timer]
OnCalendar=*:0/10

Enable the timer by running systemctl start updateip.timer

Eloy

Posted 2018-12-04T14:19:02.403

Reputation: 58

I did but IP on noip is not updated.When running ExecStart=/usr/bin/curl -X GET 'https://dynupdate.no-ip.com................ I get:X command not found.The reason for opening this thread was that there was a certişficate error which could not be reproduced by noip support.https://1drv.ms/u/s%21Am4yMVdZjYGSgYwp5tnXweWVLR5JLQ today I did not see this error but Ithere was no IP update: https://1drv.ms/u/s%21Am4yMVdZjYGSgYwyHUu-aSnX5eRI2w

– ddinc – 2018-12-05T08:37:13.367

Solved............. – ddinc – 2018-12-07T10:02:00.770