I'm trying to figure out how to create a daemon that will take screenshots every 5 minutes on OSX.

The daemon with launchctl seems to run under a separate session so the screenshots I'm getting right now are just of my blank home screen rather than my actual current session screen.

Currently I have a screencapture script:


screencapture ~/Desktop/$(date +%y%m%d%H%M%S).png

And a plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  • So you’re looking to get the OS to let you capture things on the screen like a key logger / spy program. How are you loading this script in to launchd?
    – bmike
    Apr 23 '20 at 20:49
  • Pretty much. But just want it to track what I'm spending my time doing. Just using launchctl load -w
    – Nick
    Apr 23 '20 at 23:23
  • @Nick Have you figured out how to make it work?
    – kikulikov
    Jan 12 at 11:01
  • Are you running this under your own account or under root?
    – ErniePC12
    Jan 13 at 14:42
  • Are you prepared to consider other automation methods? I am thinking about Keyboard Maestro which I am sure would do want you want (with bit of effort).
    – Gilby
    Jan 15 at 9:51

In the comments to the question you say "But just want it to track what I'm spending my time doing".

Interpreting your underlying question as being how to track application usage, I will risk being downvoted for not answering your question as in its title.

I think that a large collection of screenshots is not the best way to track what you are doing. Certainly further analysis will be complex.

To track application usage, I use Keyboard Maestro with a one action macro.

enter image description here

This creates a CSV file with three fields: Date, Time and Application name.

That will provide application usage in a form which is amenable to further analysis.


A simpler way to do this is to use cron - Automate running a script using crontab on macOS.

Also, the screencapture command has timer support:

screencapture -T 600 timedshot.jpg

(The above command will take a screenshot every 10 minutes, i.e. 600 seconds).

  • It's not always easy to understand why people downvote. If I should guess, somebody maybe downvoted because your answer doesn't answer the question as such and sends people off site for a potential alternative solution. It's also not clear how using cron instead of launchd solves the "the screenshots I'm getting right now are just of my blank home screen" problem.
    – nohillside
    Jan 17 at 13:04

I'm guessing your issue is not the command but permission. System Preferences > Privacy Settings > Screen Recording: Select Terminal & allow it.

Screen Recording Permission for Big Sur

Update: If it's still not working, additionally to above you can try taking screenshot as a specific user;

In Terminal, get the user id with the command below

id -u "username"

Then try editing your command as;

launchctl asuser UID screencapture ~/Desktop/$(date +%y%m%d%H%M%S).png

So you can launch the command as your personal account user.

  • Hmm, I suspect your guess is correct, but I don't think Terminal is the right app to allow? Launchd doesn't use the Terminal app! Jan 16 at 4:18
  • It's a bash script and executed by the terminal.
    – siniradam
    Jan 16 at 8:33
  • 1
    Terminal is not involved if a bash script gets executed by launchd.
    – nohillside
    Jan 17 at 13:01
  • @nohillside I see. Blank desktop behavior is related to permissions. I am almost certain that, something should appear on that list once the action is triggered. Maybe it can be specifically triggered by adding "run shell script" or adding terminal to the automation.
    – siniradam
    Jan 18 at 4:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .