I have a problem with a script not working when executed via crontab. I've already searched for similar problems, but none of the usual solutions seem to work. I'm using a RPi3 with raspbian stretch to run a seafile server with mysql and nginx.
The script is quite simple, it enables (outgoing) internet access (adding some IP6Table rules), starts a curl request to update my IPv6 address (DNS service) and disables (outgoing) Internet access again (deleting IP6Table rules again). Obviously, I deleted the correct login data in the code below but in my copy, it's there. (sleep 2s only for testing purposes):
#!/bin/bash bash /root/scripts/enable_internet_access.sh sleep 2s echo "Starting curl request" /usr/bin/curl -v "https://Host-ID:PW@v6.members.feste-ip.net/nic/update?hostname=Host-URL" > /root/scripts/curllog echo "curl done" sleep 2s bash /root/scripts/disable_internet_access.sh
I'm calling it with a simple (root) crontab entry, added via sudo crontab -e command:
*/30 * * * * /root/scripts/updateip.sh > updiplog
I've made sure that the crontab file has an empty line as its last line.
Now if I'm looking at the logfiles, updiplog often only contains "Starting curl request" but not "curl done", although it seems to run completely since outgoing internet access is forbidden, which indicates it runs the last script. Also, the curllog is empty. However, when started manually, everything works fine and curllog contains the correct response (usually ip still valid/no change and the ip itself).
Usual solutions seem to be:
- using full path for curl, which I've done
- considering changed environment variables (especially path), but this shouldn't be an issue here?
- ensuring that crontab ends with an empty line
- setting correct user rights. All scripts have 755 rights with owner root:root.
I'm rather new to linux / raspberry, so maybe I'm missing something obvious here?