Download Bash script from https://github.com/khaudennis/Scripts/blob/master/Bash/update-cloudflare.sh using wget
or curl
:
wget -O https://github.com/khaudennis/Scripts/blob/master/Bash/update-cloudflare.sh
curl -O https://github.com/khaudennis/Scripts/blob/master/Bash/update-cloudflare.sh
This script was forked from https://gist.github.com/Tras2/cba88201b17d765ec065ccbedfb16d9a.
Edit the script and modify the zone, dnsrecords, cloudflare_auth_email, and cloudflare_auth_key. The zone is your domain apex aka dennisdoes.net. The dnsrecords is your subdomains aka www.dennisdoes.net or test.dennisdoes.net. Cloudflare_auth_email and cloudflare_auth_key is your Cloudflare account and API Tokens which can be found in "My Profile" on Cloudflare.
Move the script to where you would normally store all your scripts. I placed mine in /usr/local/bin
.
Make the script executable:
chmod +x update-cloudflare.sh
Install jq
;
sudo apt update && sudo apt upgrade -y && sudo apt install jq -y
Edit crontab to add your script, be sure to change username to the account that owns the script:
sudo crontab -u username -e
Add your script to crontab, pointing it to where you saved the script:
*/1 * * * * username -f /usr/local/bin/update-cloudflare.sh
This script is set to run every minute with the following schedule expression */1 * * * *
.
Additional Commands
To view your crontab without modifying it:
sudo crontab -u username -l
Troubleshooting
To check logs for troubleshooting, run the following:
sudo grep -i cloudflare /var/log/syslog
sudo grep "update-cloudflare.sh" /var/log/cron
For Internal Use: \Machine Notes\2022 NIX Crontab