1

I need to restart an application once a day because it has memory leak and it ends up consuming several Gig of memory after a few days. Poor programming perhaps, but the developer wasn't able to replicate the issue. I am encountering the problem in MacOS 10.13. There is little motivation from the developer to try and help resolve the issue on an outdated version of MacOS.

I put together a small script to restart the said application. However, the script only worked for a few months, now I started getting the following error message whenever the script runs:

Application isn’t running. APPLICATIONNAME got an error: Application isn’t running. (-600)

The script is as follows:

#!/bin/bash

#!/usr/bin/osascript

tell application "APPLICATIONNAME"
    quit
    
    delay 30
    
    tell application "APPLICATIONNAME" to activate
end tell

How do I resolve the error?

2
  • Remove the the first line of the script that contains- #!/bin/bash. Move the line #!/usr/bin/osascript to the first line of the script. Make sure that the script has the execute bit set. Please post if this helps run your srcipt.
    – fd0
    Jul 18, 2022 at 19:37
  • DIdn't work, still getting the error. Hope I am not doing some elementary mistake with this because I am not much familiar wth scripts. Jul 19, 2022 at 4:06

2 Answers 2

2

It works for me, but there's an odd tell 'bracketing' that I had initially assumed may be the problem.

You're opening your tell block, then within it using another one-shot 'tell to' then closing the original tell. That just looks odd, even though it seems to work anyway.
The logic being that as the main tell block is still open, the original PID of "APPLICATIONNAME" may still be what it is holding in memory & perhaps trying to re-apply it later, when it no longer exists. [Guesswork]

I'd try

tell application "app" to quit

delay 30

tell application "app" to activate
0

Didn't work for me.

Here is my script now..

#!/usr/bin/osascript
tell application "app" to quit
delay 30
tell application "app" to activate

I also set the execute bit, changed to the directory where the file is and executed: chmod=+x scriptname.sh

When I run the script in Script Editor, regardless whether the application "app" is running or not running, when I execute it, the application is restated but I am getting this message:

error "CloudMounter got an error: Application isn’t running." number -600

The strange thing is, if the application wasn't running, after executing the script the application is executed and runs.

I haven't even tried to run the script in my scheduling app because I assume I also would get the same error message.

2
  • You ought to edit this current research into your question, as it's not actually an answer. What's CloudMounter? is that the app you're trying to launch? btw, I'm not sure the osascript line is needed at all. It's not using osascript [though I've not much experience of it myself] Doesn't make any difference to my version here. Try a different app too. I'm testing using Notes.
    – Tetsujin
    Jul 19, 2022 at 10:07
  • I am a newb so have no idea where to type in stackexchange. This doesn't work either. Tried with Evernote for instance,.. same error. Sep 28, 2022 at 6:29

You must log in to answer this question.

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