Hi,
I have setup a default ZT network, but I have problems forwarding a crontab command to one of the machines on the network. It works when I use a simple HTML link in a browser, but not from crontab. Any ideas?
Sounds more like a cron problem than Zerotier. At a glance, this may be the problem that there’s no path in the shell used by cron to get to the wget binary. Try adding the full path:
0 0 * * 1 /usr/bin/wget …
using “which” to determine the actual path of wget on your system.
You might also want to wrap this in a script so that you can change the working directory to wherever you want this file to be dumped to.
I tried with your suggestions and with /usr/bin/lynx as well. It did not work.
I do not need to retrieve anything, just to get the command through. It works when I trigger a link in a browser, but not through crontab or cli.
I will try with httpie tomorrow: /usr/bin/http.
I have also made a script that pings the machine first before executing a command. I have tried with scripts before, to no avail. The endpoint is a machine on 4G. I find it strange that I can use a link in a browser but not getting anything through via crontab. Even to type the command directly in cli does not work either. Only the browser works, when the client computer is on the same ZT network ofc. There must be something that blocks it on the server.
My last resort might be to get a small computer and put it directly on the same switch.
I will investigate further. Thank you for your time.
Just did a quick topology. All routers are running OpenWRT. The End-Device is getting the command from one of the PC’s in the network. Also, Device1-3 are streaming audio to the End-Device without issues. All can ping each other. Hope that this diagram can help.
It sounds like the network side of things is working as expected. There’s something about the web page you’re requesting that doesn’t work over curl or wget then it may be that there’s something on the web request that’s missing. Perhaps it needs to be launched from that page so that the referrer value is included in the request (which can be added manually). It also may be that it requires a hostname in the URL vs an IP address…
What is the error returned when you run the command directly in a terminal?
Thank you for your reply. It works now.
You gave me a good idea, to include the Content-Type Header.
Send the HTTP request with the Content-Type header: curl -s -H "Content-Type: text/html" "http://10.0.0.209/rc.cgi?r=1&c=1" >/dev/null 2>&1
Script:
----------------
#!/bin/bash
# Set the IP address to ping
ip="10.0.0.209"
# Ping the IP address
if ping -c 3 "$ip" > /dev/null 2>&1; then
# Run the command if the ping was successful
curl -s -H "Content-Type: text/html" "http://$ip/rc.cgi?r=1&c=1" >/dev/null 2>&1
else
echo "Ping to $ip failed."
fi
----------------
I have included a ping function, because sometimes it times out on 4G.