Skip to content

Instantly share code, notes, and snippets.

@catleeball
Last active June 12, 2023 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catleeball/835441348ffd4799a91c14df3d270fe5 to your computer and use it in GitHub Desktop.
Save catleeball/835441348ffd4799a91c14df3d270fe5 to your computer and use it in GitHub Desktop.
Simple cron job to update host file with spam block list
#!/usr/bin/env bash
#
# Simple cron job to update host file with spam block list
# /etc/cron.daily/hosts_update.sh
wget -q https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts -O /tmp/hosts
if ! cmp /tmp/hosts /etc/hosts >/dev/null 2>&1; then
mv /tmp/hosts /etc/hosts
else
rm /tmp/hosts
fi
# Restart your system's network daemon to pick up new changes
# This can vary by distro! You may want to change this!
systemctl restart systemd-networkd
@jfoclpf
Copy link

jfoclpf commented Jun 11, 2023

Nice, I guess I just need to add this file to /etc/cron.daily to be run by anacron

@jfoclpf
Copy link

jfoclpf commented Jun 11, 2023

I would still add service network-manager restart to be sure dns cache is cleaned up

@catleeball
Copy link
Author

good callout @jfoclpf ! I'll update this with a note

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment