0

I would like to execute a script on my machine every five minutes, even when I am not in front of my mac OS X Yosemite. Therefore, I would like to lock my session and shut off the screen while the computer stays active. How can I do that. I have tried with a crontab.

Let's say this is my script :

#!/bin/bash
D=`date +%Y%m%d.%H%M`
echo "Hello" > "test_$D.txt"

and this is my crontab entry

*/5 * * * * /MyPath/script.sh > /MyPath/log

When I do this, and when I lock my session, or start the screen saver, the crontab doesn't execute, which mean that I need to keep my session and my screen open all day long. Is there a way to do what I want to do with a mac?

2
  • 2
    Cron jobs should execute even while the screen saver is running. Does the job execute correctly every 5 minutes while the computer is running?
    – nohillside
    Commented Jan 24, 2017 at 5:45
  • Actually, whenever you write a cron job, test it by running it directly. It's a good practice, you'll be sure it works before actually putting it in a cron. Commented Jan 24, 2017 at 15:00

1 Answer 1

2

Patrix got it right. I have made a mistake in my bash script, which caused error... Sorry for the post.

1
  • It's helpful if you post what your mistake was and what you did to fix it. As it stands, this is more of a comment than an answer.
    – Allan
    Commented Jan 24, 2017 at 18:14

You must log in to answer this question.

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