Score:1

write to /etc/host from cron each for n minutes of each hour

ru flag

i need help with bash script and cron. The simple idea is to lock some website domain name for n minutes of each hour, (45 minutes of each hour but randomly lock youtube.com or facebook). I do not know how the bash script should be and which cron rule need to use and how to run it with root rights ?

*/45 * * * * for cron rule but how to make it run randomly (0-45 or from 10-55 ...) And how should look like bash script (which lock the domain name or write to host file)?

in flag
Browsers are going to cache DNS locally, so this may not work as you expect it to …
wer4ty avatar
ru flag
i am trying to create bash script which will be run by cron, but it not so easy as i thinking
chili555 avatar
cn flag
"cache DNS locally" dnsmasq: https://help.ubuntu.com/community/Dnsmasq
Score:0
cn flag

I would definitely do this by editing the host file.

this could be more complicated but here's how I think of solving this problem:

2 bash scripts (one to add a block and another to remove the block) create an extra hosts file (with the domain block entries) the bash scripts will just swap the hosts files two cron jobs that run at the proper times to run your bash scripts that either enable or disable the block (cron jobs as root of course since they're changing the hosts file)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.