Posts Tagged ‘launchd’

Launchd Daemon to block Social Media on macOS

Tuesday, September 26th, 2017

Years ago I had an anacron job that would automatically block the forums I tended to want to read during my work day, and then automatically unblock them when the workday was over. By “block”, here, I mean redirect to local – so that when I went to those websites by typing them into my browser, I’d get just a DNS error saying the page couldn’t be found. I used anacron (instead of cron) because the tasks would “run” even if no user was logged in, even if the computer was asleep, or off… etc. Anyway – I did this as a little productivity hack.

After a week off twitter recently, I decided I wanted to bring this hack back – except updated for social media, not Something Awful. But it turns out … macOS has deprecated cron / anacron and launchd has adopted their functionality.

What follows is a tutorial on how to schedule a launchd daemon to block, and unblock, social media on your computer from 11am to 2pm and then 3pm to 8pm.