Skip to content
Lock Mac screen on inactivity even when configuration profile is configured
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This cron job is intended for people who want their Mac to auto-lock after inactivity period, but can't define the Screen Saver "Start after:" parameter (in my case - because of a Mac configuration profile enforced by my employer). It requires you set your Mac to lock when screen saver starts. Your Mac won't lock if there's something preventing it from sleeping, like watching a video.


  1. Copy to your favorite executable path (e.g ~/bin/
  2. chmod +x ~/bin/

In order to make this script run periodically, you need to define it as a cron job. Do that by editing your crontab file:

  1. Run env EDITOR=vim crontab -e
  2. Add the following line to the prompted editor: * * * * * /Users/<youruser>/bin/ (replace with your Mac username).


The 5 asterisks in the beginning of the line mean this script will every minute (lowest resolution a cron task can run in). Feel free to change the cron timing parameters to suit your needs.

The script itself is set to launch screen saver after 60 seconds of inactivity. It's defined within the script in an easy-to-change variable.

You can’t perform that action at this time.