Crontab task "LSOpenURLsWithRole() failed ... with error -600 for the file ..."

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?


Solution 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.