I'm using a terminal command to replace the /etc/hosts - file.
alias nonews="sudo -S chattr -i /etc/hosts < /etc/password_file && sudo -S cp /etc/hosts_all_blocked /etc/hosts < /etc/password_file && sudo -S chattr +i /etc/hosts < /etc/password_file"
Where the hosts_all_blocked is a file with which distracting webpages are blocked. And the /etc/password_file contains the sudo-password.
So after using I want the relevant pages to be blocked immediately. I tried the command and sometimes it works immediately as wished, but sometimes even if the file has changed, there is no effect on the possibility to open webpages.
How can I ensure that the changes in the /etc/hosts are having an immediate effect?
Btw: For the unblocking I'm using a 20-minute delay:
alias getnews="sleep 1200 && sudo -S chattr -i /etc/hosts < /etc/password_file && sudo -S cp /etc/hosts_all_allowed /etc/hosts < /etc/password_file && sudo -S chattr +i /etc/hosts < /etc/password_file"