Hello there,
I reused a script I found on this forum after some modifications to update the dyndns. The script is working fine, when I go to the script and run it (ie “/system/script> /system/script/run updateDynDNS”).
Now I want to run this script periodically using the scheduler. I have configured a scheduler like this:
/system scheduler
add comment=“Run dyndns update script periodically " interval=3m name=ScheduleDynDNS on-event=”/system script run updateDynDNS" start-time=startup
I also tried to configure it like this:
/system scheduler
add comment="Run dyndns update script periodically " interval=3m name=ScheduleDynDNS on-event=updateDynDNS start-time=startup
The thing is, I can see the scheduler times it ran is increasing, however my script is not being executed (no log entries and the dyndns record isn’t being updated like it is when I manually execute the script). I’m on ROS 7.16 hEX PoE. Anybody got an idea what the issue could be?
My script
/system script
add comment="This scripts updates Joker dyndns" dont-require-permissions=no name=updateDynDNS owner=admin source="#https://wiki.mikrotik.com/wiki/Manual:Tools/Fetch#:~:text=Learn%20how%20to%20use%20the%20/tool%20fetch%20command%20to%20download,\
\n#Testing:\
\n#https://svc.joker.com/nic/update\?username=XXX&password=XXX&hostname=XXX&myip=1.1.1.1\
\n#dig +short XXX @x.ns.joker.com\
\n\
\n# Set needed variables\
\n:local username \"XXX\"\
\n:local password \"XXX\"\
\n:local hostname \"XXX"\
\n\
\n:global dyndnsForce\
\n\
\n\
\n# get your public IP\
\n:local result [/tool fetch mode=https url=https://ipv4.svc.joker.com/nic/myip as-value output=user];\
\n:local resultData (\$result->\"data\")\
\n\
\n# parse the current IP result (grab first line)\
\n:local currentIP [:pick \$resultData 0 [:find \$resultData \"\\n\"]]\
\n#:log info \"UpdateDynDNS: currentIP = \$currentIP\"\
\n\
\n#resolve the DNS record\
\n:local resolvedip [:resolve \$hostname]\
\n\
\n\
\n#uncomment line below to force dyndns update, beware of blacklisting by DNS\
\n#:set dyndnsForce true\
\n\
\n#If DNS record is different from my public IP OR dyndnsForce is true; update DNS record through dyndns\
\n:if ((\$currentIP != \$resolvedip) || (\$dyndnsForce = true)) do={\
\n:set dyndnsForce false\
\n:log info \"UpdateDynDNS: Dyndns update needed. PublicIP: \$currentIP ResolvedIP: \$resolvedip\"\
\n:local dyndns [/tool fetch mode=https url=\"https://svc.joker.com/nic/update\?username=\$username&password=\$password&hostname=\$hostname\" as-value output=user];\
\n:local dyndnsres (\$dyndns->\"data\")\
\n:local strippedResult [:pick \$dyndnsres 0 [:find \$dyndnsres \"\\n\"]]\
\n:log info (\"UpdateDynDNS: Dyndns Update Result: \".\$strippedResult)\
\n} else={\
\n:log info (\"UpdateDynDNS: No dyndns update needed\")\
\n}"