K0p1-Git / cloudflare-ddns-updater

Dynamic DNS (DDNS) service based on Cloudflare! Access your home network remotely via a custom domain name without a static IP! Written in pure BASH~
MIT License
1.33k stars 370 forks source link

Add cron designations #52

Open nlare opened 1 year ago

nlare commented 1 year ago

I believe this is specific to Debian but cron would not run this script without designating the shell and path priority first:

SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/

Posting this for other noobs such as myself.

Wizman87 commented 1 year ago

The environment variables mentioned should have those values assigned to them by default. I also verified on my end with my Debian GNU/Linux 10 "Buster" installation and the listed environment variables are indeed set to those values. With that said though, if such an issue were to arise for anyone in the future, what you've written here is a good reference point for those that are running bash scripts on other distributions! The default values of these environment variables can be found documented online as well. Lastly, the following terminal command and example(s) or line(s) of code can also be added directly to crontab to specify the specific shell and/or script path desired by the user:

$ crontab -e
* * * * * /bin/bash /root/cloudflare-template.sh
* * * * * /path/to/shell /path/to/cloudflare-template.sh

I hope that helps!

haciz commented 2 months ago

crontab -e

And then add the line and it will run every 3h

0 */3 * * * /bin/bash cloudflare-ddns-updater/cloudflare-template.sh

to see the current active cron jobs crontab -l