MacOS – AppleScript executes itself again after a reboot it initiated. How to avoid that

applescriptcommand linemacosrestart

I have a shell script that is run by an AppleScript app.
That shell script restarts the machine at some point with shutdown -r now.

How can I avoid having the AppleScript application automatically launch itself again after the reboot?

  • The app is not included in the startup items
  • The app is launched again just like any other open app when the shell script restarts OS X

The sequence is this:

  1. I double click on the AppleScript app
  2. AppleScript launches a shell script in Terminal
  3. The shell script, at some point, reboots the system
  4. The AppleScript app starts again after the reboot

Best Answer

Have your AppleScript write an empty file to a predefined location and test for its existance when the script starts. If the file is already there, delete it and quit the script; otherwise proceed as normal and reboot.