I wrote an applescript that turns on my lights. I exported it as an application with the name "LightsOn", and it appears with that name in activity monitor.
Under certain circumstances, this app gets stuck. I can force quit it from Activity Monitor, but I want to be able to do so from a script. killall LightsOn
doesn't work; I'm told that no matching processes belonging to you were found
.
How can properly force quit this app from the terminal? Or, how can I discover the appropriate name for killall?
Best Answer
The reason
killall LightsOn
doesn't work is because all running AppleScript application's process name isapplet
. For example, the executable path is:In general and assuming the process(es) is(are) not hung, one could use
killall applet
however that will terminate all running AppleScript applications, and of course that may not be desirable.When a process is hung, you'll need to use a
KILL
signal, e.g.:However,
pkill
is the way to go to easily target a specific AppleScript application and because it's hung... use aKILL
signal, e.g.:Or:
Note in this instance,
-9
is just another way of saying-KILL
.Now with
pkill
and using the-f
option, one can use more of the full argument list, e.g.:Then there's no ambiguity as to which
applet
process one is targeting. One can use as much of the full argument list as one feels is necessary to target the correct process.For example,
pkill -9 -f LightsOn
will terminate an AppleScript application namedNoLightsOn
, so always use enough of the full argument list to terminate the correct process.For reference:
From the
pkill
man page:From the
killall
man page:Note that this is just a partial signal list and is used with many of the different utilities that can terminate a process. See the various manual pages of the utilities used for additional information.