1

I just moved to a new MacBook with El Capitan and trying to set up my crontab to do backup tasks. Here is how I have it set up (via crontab -e)

40 7 * * * /Users/myusername/daily.sh "daily tasks run 7:40a"

Daily.sh looks like this

open -b com.apple.terminal ~/backupThing1.sh
open -b com.apple.terminal ~/dailyThing2.sh

I have it set up this way so I see the terminals come up and can respond to some inputs and password prompts.

Anyway, this task fails with the following messages:

LSOpenURLsWithRole() failed for the application /Applications/Utilities/Terminal.app with error -600 for the file /Users/myusername/backupThing1.sh.
LSOpenURLsWithRole() failed for the application /Applications/Utilities/Terminal.app with error -600 for the file /Users/myusername/dailyThing1.sh.

I have verified that these scripts are owned by myusername and are executable. What am I missing?

1

As noted in the other answer the error is because you are trying to run a GUI app when not logged in.

However in your case why are you using a GUI app (Terminal ) here.

Just call your scripts directly from the cron script.

e.g. daily/sh should be

#!/bin/bash
~/backupThing1.sh
~/dailyThing2.sh

Note that you might need to have absolute paths not ~ here as cron jobs do not have the same environment as when run in the terminal.

  • you can use $HOME in place of ~ in most contexts where ~ doesn't work. – iconoclast Oct 27 '18 at 0:05
0

You will see this error

LSOpenURLsWithRole() failed with error -10810

if you try to run most open commands (including for Calendar, PhotoBooth, etc.) without a user being logged in via the actual GUI. If you're remote, attach using VNC and log in. Otherwise just log in using the regular OS X GUI (i.e., the login screen we humans use).

You must log in to answer this question.

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