Friday, 6 September 2019

macos - Automatically change /etc/hosts on OS X 10.6


I edit /etc/hosts as a first line of defense to stop me going to certain distracting sites during the working day.


Ideally I'd like to have two versions of hosts and a cron job that switches them at 9am and 5pm during the day, but I think that there is a permissions issue running cron under sudo... should I just reduce the permissions on hosts?



Answer



You shouldn't need to change permissions of any system file.


I don't see any issue just doing everything under root, i.e. by opening a root shell, and editing the crontab.


sudo -i
crontab -e

You can also directly edit root's crontab with:


sudo crontab -u root -e

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...