0

Is it possible to lock the screen in OS Yosemite using code? And then put in a scheduler to run every two minutes?

If so what script language are we talking, task scheduler program etc

1

Here is the way I would try completing this task:

  1. Create a script file that will be executed every time the system starts:
sudo nano ~/sleep.sh
  1. Input the following text in the file:
#!/bin/bash
sleep 120
pmset sleepnow
#osascript -e 'tell application "System Events" to sleep'

Note: The last line with the # at the front is a substitute of the one above (pmset sleepnow)

  1. Open the CronJob editor in order to start the script frequently:

env EDITOR=nano crontab -e

  1. Input rule for the script to be started automatically

* * * * * sh ~/sleep.sh

  1. Re/start the current CronJobs:

sudo touch /private/etc/crontab

P.S. I haven't tested it, but I will gladly help if anything additional is needed.

You must log in to answer this question.

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