I have the following:

* * * * * open -a /Applications/TextWrangler.app/  ~/notes.txt; open /Applications/Notes.app

Neither of the 2 apps brings focus to the foreground (though they do get launched in the background) so the whole job is a bit pointless (it's to remind me to make some notes at the end of each day at work).

It works if I copy and paste the commands into a terminal. So why does cron behave differently and can this be changed?

  • Try reattach-to-user-namespace (available on homebrew and elsewhere)
    – 0942v8653
    Nov 1, 2019 at 1:26
  • 2
    cron jobs can run as your user, but aren't actually part of your user session. Could you use a Launch Agent instead? Nov 1, 2019 at 3:12
  • 1
    On macOS High Sierra, * * * * * open -a TextWrangler ~/notes.txt; open -a Notes; works as is for me, both apps come to the front. Try adding ; osascript -e 'tell app "TextWrangler" to activate' -e 'tell app "Notes" to activate' to the end of your existing command and see if that makes any difference. Nov 1, 2019 at 3:52
  • The Applescript approach works so I'm going to go with that. Thanks for the other suggestions. But anything that involves learning a non-transferable skill or install extra software will always be a 2nd choice :) Feel free to post as an answer so I can give credit. Nov 1, 2019 at 17:42

1 Answer 1


For me on macOS High Sierra, e.g.:

 * * * * * open -a TextWrangler ~/notes.txt; open -a Notes

works as is, both apps come to the front.

Try adding, e.g.:

; osascript -e 'tell app "TextWrangler" to activate' -e 'tell app "Notes" to activate'

to the end of your existing command and see if that makes any difference, e.g.:

* * * * * open -a TextWrangler ~/notes.txt; open -a Notes; osascript -e 'tell app "TextWrangler" to activate' -e 'tell app "Notes" to activate'
  • Personally, I'd put these commands in a shell script file and call the shell script from cron. That would make it much easier to edit and format, without having to worry about cron formatting or anything like that.
    – TJ Luoma
    Nov 2, 2019 at 3:28
  • 1
    @TJ Luoma, I don't disagree, however it does work as is and as the saying goes, if it's not broke don't fix it, but that's up to Sridhar Sarnobat to decide how he wants to handle it. (He asked me to post my comment to his OP as an answer, so I did.) Nov 2, 2019 at 3:38
  • 1
    I've learnt the hard way that shell scripts to simplify cron entries is counterproductive. You end up unable having difficulty locating the culprit of strange behavior that is caused by a command buried in a shell script whose name is misleading ;) Nov 2, 2019 at 6:19
  • 1
    @Sridhar Sarnobat, I do not know if you know this, however, cron will write an error message to mail, which you can access from Terminal using the mail command. That said, the error messages can be cryptic too. :) Nov 2, 2019 at 6:23

You must log in to answer this question.

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