Applescript to quit a daemon?

So, now and then I need to quit/kill/restart a daemon. Well, I use other Applescripts to quit applications, but apparently, quitting a daemon is not the same. Both show up in the Activity Monitor, but trying to apply a quit and app type script to a "daemon" does not work. I like to use an applescript as then I can just click it and it runs versus having to open Activity Monitor, searching for the daemon, selecting and quitting. 1 click versus like 5 clicks.
For example, I use this to quit an app..
tell application "Dock" to quit
but trying to put in a daemon service in place of "Dock" app does not work becuase this script is looking for an "application"
So, does anyone know of a simple script just like this that can be written to quit a daemon?

Just killing a daemon will not necessarily restart it.  How is the daemon started in the first place? It would also help if you told us which daemon you are referring to here.
In OS X background processes like this are controlled using launchd/launchctl. It would be best if you worked within that system.
So just killing the process isn;t the answer unless you do not what it started up again.
it is one for an app that unless the daemon is restarted a portion of the visual monitor displayed in the apple menu will not work.
Interesting, could you share the name of this program and what ir does ?
Just like I run a 1 click applescript to kill my dock to regain control of my widgets (as that is an issues no one has ever been able to solve, but a different issue posted about elsewhere).
What issue is this?
BTW what version of the OS are you running that might also affect the answer.
regards

Similar Messages

  • Help with applescript to quit certain processes by name?

    Hey, for anyone who knows how to program applescripts well, I could use some help with the script below.
    I'm very new to applescripting and I'm trying to write a script that would automatically quit up to 100 instances of the Google Chrome Renderer process.
    Thanks to google, I found a script similar to what I wanted, and after some tinkering I thought I had it just right. The thing is, if I only set the app_name to Google Chrome, it quits Chrome just fine, but when I try it like this, it doesn't receive any data from grep or awk.
    If anyone can help I'd really appreciate it.
    repeat 100 times
              set app_name to "Google Chrome Renderer"
              set the_pid to (do shell script "ps ax | grep " & (quoted form of app_name) & " | grep -v grep | awk '{print $1}'")
              set new_pid to first word of the_pid
              try
                        if new_pid is not "0" or "1" then do shell script ("kill -9 " & new_pid)
              end try
    end repeat

    try this:
    tell application "System Events"
              set procs to (every process whose name is "Google Chrome Renderer")
              if (count of procs) > 100 then
                        set max to 100
              else
                        set max to count of procs
              end if
              repeat with i from 1 to max
                        tell (item i of procs) to quit
              end repeat
    end tell

  • Ensure AppleScript App Quits

    I have an AppleScript saved as a run only app which I call every hour from launchd.
    Most of the time it works fine, but occasionally something causes the app not to quit when it's done its thing.  This means that next time an error is thrown and the process does not run (so it fails until I force quit the app).
    I have tried wrapping the whole script in a try...with timeout...end timeout...on error return...end try structure but that makes no difference.
    The core of the script is a run shell script that calls a perl script which in turn gets data from a web site.  I have tried nesting a try...on errror...end try around this that simply sets the content of the variable that should be populated from the script in the event that any error occurs.
    The final part of the script is opening a [text] file and inserting a few lines at the top.  Again I have tried wrapping this in a try...on error return...end try stricture.
    None of these efforts seems to have any effect.  However, I can't get the script to fail when I run it from the ApplScript Editor.
    Would I be better to use osascript to call a script rather than the app, or am I doing something more fundamental wrong?

    I'm not trying to be coy either, but I don't see that posting the whole script is going to help particularly because the perl script uses WWW::Mechanize to get data from a website where I have to provide user credentials - hence, it will not be possible to run it without those credentials.
    The expectation is that I will get approximately ten lines of data back (which I put into a local variable).  I then use an offset check to determine whether a particular string is present.  If it is present, I then go on to compose a message (using Messages) to send to myself.
    Regardless of the content, I open a local text file and insert the web response at the beginning of the file (as an activity log).  The file is then closed for access and that's it.
    I have only once seen an error when I ran the script from the AS Editor and this seemed to indicate a problem with the site's availability - so when Mechanize couldn't find any identifiable data, it threw an error.
    The app is not saved as stay open, but it does.  All I can say for certain is that the log file does not get written to, so I suspect that the problem lies with the perl script.  It is for that reason that I wrapped it in a try...with timeout structure.  (My understanding of the timeout, is that if script execution fails to complete within the timeout an error will be thrown, so this is picked-up by the try...on error.  That understanding may be wrong.)
    So, after all that, here is the script [with a single hard-coded address obscured for privacy]:
    try
              set desktopPath to (path to desktop) as alias
              set FlightCheckLog to (desktopPath as text) & "FlightCheckLog.txt"
              set targetList to {"Sep-7", "Sep-8", "Sep-9", "Sep-10"}
              tell application "Messages"
                        set theBuddy to buddy id "<OBSCURED>"
              end tell
              set messageSent to false
              try
                        with timeout of 300 seconds
                                  set theFlights to do shell script "~/Documents/perl/FilghtCheck.pl -x -c J -d 2013-09-07 ATH-LHR"
                        end timeout
              on error
                        set theFlights to ""
              end try
              repeat with theDate in targetList
                        set theOffset to (offset of theDate in theFlights)
                        if theOffset is not 0 then
                                  set theFlight to text (theOffset - 5) thru end of theFlights
                                  set theReturn to (offset of return in theFlight)
                                  set theFlight to text 1 thru (theReturn - 1) of theFlight
                                  tell application "Messages"
      send theFlight to theBuddy
                                            set messageSent to true
                                  end tell
                        end if
              end repeat
              try
                        set theFile to open for access FlightCheckLog with write permission
      get eof theFile
                        if result > 0 then
                                  set fileText to read theFile
      set eof theFile to 0
                        else
                                  set fileText to ""
                        end if
                        if messageSent then
                                  write ((current date) & return & theFlights & return & "MESSAGE SENT" & return & return & fileText) as text to theFile
                        else
                                  write ((current date) & return & theFlights & return & return & fileText) as text to theFile
                        end if
      close access theFile
              on error
                        return
              end try
    on error
              return
    end try

  • Need applescript help, quit application upon sleep

    I have never worked with applescript before, so I am completely lost.  I have a program that does not like to like to be open when the computer goes to sleep.  I usually remember to close the app, but sometimes I forget and get myself in trouble.  If I do forget, very bad things can happen to the database of the program, so it is imperative that it is closed.
    I am hoping there is an applescript that will quit the application if I put my laptop to sleep, usually by closing the lid.  I don't want to trigger the sleep with the applescript, just something that will see that the computer is going to sleep and quit the application before it happens.
    Is this possible, and if so, how do I go about doing it?
    Thanks,
    Brandon

    SleepWatcher - A utility to run tasks on sleep/wake

  • Applescript to quit an application

    I have a very simple Applescript written and saved as an application to quit GoodSync, a syncing program.  When I run the script from within applescript the application quits.  When I run the application as a stand alone it fires but does not quit the application.
    any ideas?
    tell application "GoodSync"
      quit
    end tell
    The applicaton does not ask to save anything on quit.
    I have used automator to the same end and it works as a stand alone application.
    Eager to learn,
    Thanks in advance,
    Debbie

    Frank,
    The Shell works but sends back a bunch of errors. 
    tell application "System Events"
      get unix id of every process whose name = "GoodSync"
      --> {4370}
      do shell script "kill -9 4370"
      --> error number -1708
      «event ascrgdut»
      --> error number -1708
      do shell script "kill -9 4370"
      --> error number -10004
    end tell
    tell current application
      do shell script "kill -9 4370"
      --> ""
    end tell
    Result:
    I am not familiar enough with the coding and errors of AppleScript to determine if I need to worry.  The computer also told me that my external hard drive was not ejected properly not long after I ran this script.
    Thank you again,
    Debbie

  • AppleScript App Quit Timer in Yosemite

    Hey all.  I think this is a simple question... but I don't really know.  I fall asleep with EyeTV running and wanted a sleep timer for it... years ago I found a little script online-- I think it's AppleScript... --to quit an app after a specified amount of time.  The script is:
    display dialog "Timer duration (in minutes):" default answer "180"
    delay ((the text returned of the result) * 60)
    tell application "EyeTV" to quit -- Set AppName to the name of the application you want to quit.
    That's it.  A box would pop up asking me to enter the number of minutes 'til quit (180 as the default), and after that amount of time EyeTV would quit.  The problem is, in Yosemite, no matter how much time I enter in the duration box, EyeTV quits the instant I hit return.  I imagine there was a minor change to AppleScript in Yosemite, and I'm hoping someone smarter than me might be able to spot what's changed.
    Thanks for any help.

    Better all around to avoid the delay command and use an applescript app with an idle loop.  save the following as a application from the AppleScript Editor, making sure to click the stay open after run handler checkbox, then run the application.
    global timer, flag
    on run
      display dialog "Timer duration (in minutes):" default answer "180"
      set timer to ((the text returned of the result) * 60)
      set flag to false
    end run
    on idle
      if flag then
      tell application "EyeTV" to quit -- Set AppName to the name of the application you want to quit.
      quit -- send this command so this app will quit on the next idle loop
      return 1
      else
      set flag to true
      return timer
      end if
    end idle

  • Applescript to quit an applescript

    Hi all,
    I'm trying to quit an applescript application (so should be an app, no?) through another applescript without results... even when i do a "killall myapp" from the terminal i have this error:  "No matching processes belonging to you were found"
    How can this be?
    The application i want to quit is as simple as this:
    delay 400
    do shell script "echo try>> /Users/caDesktop/dst.txt"
    Thanks!

    Your application isn't going to quit if told to quit (directly or via System Events) while it is in that long delay, since it won't get the message until the delay is completed.  The shell command killall will terminate the process, but an AppleScript application process does not have the name of the application - it has the name of the executable, which would be applet or droplet.

  • How do I get my boot applescript to quit once it has finished?

    I have a script set up to boot Google Chrome on Login in fullscreen mode in Mountain Lion
    The problem is that the script is left in my dock and it needs to force quitted to exit.
    The script seems fairly simple but I'm not sure how to get the .app script to close once its finished doing its business!
    The script I am using is pasted below:
    do shell script "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --kiosk"
    Thanks!

    your script is waiting for a response from Chrome.  you should release the command as a separate process like so:
    do shell script "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --kiosk &> /dev/null &"

  • AppleScript Studio Quit Working

    Last December (2007) I followed the tutorials in the "Introduction to AppleScript Studio Programming Guide" to create a handful of demo projects, plus one of my own invention that actually worked!
    Today I sat down to resume my learning and I found that, while the target apps I had created still work, I cannot rebuild the projects. The error message is the same in every case:
    Tool:0: Command /usr/bin/gcc-4.0 failed with exit code 1
    Tool:0: /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit
    load command 19 unknown cmd field
    To reproduce the error, I...
    Open the project's folder
    Double-click on the <projectname>.xcodeproj icon
    Click the "Build and Go" button.
    Any idea what may have changed since last December?
    --Gil

    I just encountered a problem with my project that occurs under the same circumstances: open my project file, click on the build button, and it fails with the same error:
    /usr/bin/ld: /System/Library/Frameworks/WebKit.framework/WebKit load command 19 unknown cmd field
    collect2: ld returned 1 exit status
    I just ran an update to move to 10.4.11. I get the feeling that updated Webkit, and that's causing the problem. I'm on a PPC machine running XCode 2.1 but perhaps it's time to check out 2.5.
    For what it's worth, I found that I was still able to compile using "xcodebuild" on the command line. You might try giving this a shot. From the Terminal, cd into the project's directory; then execute "xcodebuild -alltargets clean && xcodebuild build" -- this will clean the current executable then build it.
    A couple questions for you: (1) What OS are you running? (2) What version of XCode? (3) What processor architecture (Intel or PPC)?
    That's all for now.. let me know how it goes..
    On a side note, I found your post through a Google search, and it's only a day and a half old... nice.
    (Update -- Ah... I see you solved the problem by upgrading to XCode 2.5.)
    Message was edited by: Krishen

  • How can I quit Microsoft Database Daemon & SyncServicesAgent so that I can update Microsoft word?

    how can I quit Microsoft Database Daemon & SyncServicesAgent so that I can update Microsoft Office for macs?

    JamjarPW wrote:
    I tried all the solutions above, and the many others that are posted on various other forums (involving shift keys, activity monitor, dragging and dropping apps, renaming etc).  None of them worked.  SyncServicesAgent and the Daemon App would reactivate evcery single time, within seconds.
    What worked for me was to start the update installation and get to the point where it require syncservices etc to be closed.  At this point, i DISCONNECTED FROM THE INTERNET.  (I also quit syncservices and the database daemon in Activity Monitor but I don't know if that step was necessary).  Then I went back ot the update installation, clicked continue and it all went fine.
    So the answer seems to be: go offline.
    Good luck
    No, the answer is to quit the MS daemons that are running (database and syncservces), on or offline is not relevant.
    You can't quit the daemons if Office is running, so exit Office first.

  • Launch/Quit CoverSutra on iTunes Launch/Quit

    CoverSutra doesn't come with a iTunes launch/quit monitor daemon to start/quit itself when you lauch/quit iTunes. I wonder if it's possible to run an AppleScript automatically when iTunes runs to start/quit CoverSutra. I want something like the code bellow to run automatically.
    on run
    repeat
    if application "iTunes" is running and application "CoverSutra" is not running then
    tell application "CoverSutra" to activate
    end if
    if application "iTunes" is not running and application "CoverSutra" is running then
    tell application "CoverSutra" to quit
    end if
    delay 5 --infinite loop 100% CPU
    end repeat
    end run

    There is no file at that URL, only an error message.
    Is this your podcast -
    https://itunes.apple.com/podcast/soap-box-heroessoap-box-heroes/id682605938
    This is using the feed at
    http://feeds.feedburner.com/SoapBoxHeroessoapBoxHeroesPodcast
    which has four episodes; however there are no 'enclosure' tags containing the URLs of playable media, so as iTunes does not show episodes with no playable media the podcast shows as empty.
    I could only guess that that is your podcast from the title given in the error message for the URL you quote as you haven't given any further information.
    If it is, then the Feedburner feed must be working from a feed you've created, though there's no way of knowing its URL. You can move Feedburner to using a different feed easily enough, or get the feed it's using working properly, and then the podcast will be subscribable again and the Store will catch up after a few days.

  • Applescript no longer steps through iCal events in sequence

    Hi all,
    I have been using an Applescript that someone on this forum helped me write a few years ago to put unique combos of events into iCal and it has worked perfectly for me, although this year it has begun to jump around within iCal when it is adding events. In other words it used to step through the calendar and add events day by day, progressing chronologically. Now it still accomplishes the task but starts (currently) with May 1 of 2011 and moves to May 16th ... The fact that it still works is cool, but it has slowed the applescript down quite a lot.
    Here is a section of the script...thanks, dan
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into a HTML editor">
    repeat with theEvent in (events of calendar "School Calendar 10-11")
    if isitacycleday contains (summary of theEvent) then
    --Gets the current day and the cycle day number
    set cycleday to summary of theEvent
    set cycleDate to (start date of theEvent) + 1 * hours
    set cycleNumber to last character of cycleday as integer
    --There are always 7 periods in every day
    repeat with periodNumber from 1 to 6
    --Gets the subject from periodCycle
    set theSummary2 to item periodNumber of item cycleNumber of periodcycle2
    set theSummary to item periodNumber of item cycleNumber of periodCycle
    --Checks to see if there's a subject for this period, if not skips to next one
    if theSummary2 is not "" then
    set theStart to date (startTime of item periodNumber of periodTimes) of cycleDate
    set theEnd to date (endTime of item periodNumber of periodTimes) of cycleDate
    --Makes the event in the calender whose name is defined at the top of the script
    make new event at end of calendar TargetCalendar with properties {summary:theSummary, start date:theStart, end date:theEnd}
    end if
    end repeat
    end if
    end repeat </pre>

    Hi Bernard,
    right, I believe you were the one that came up with this script! It still does the trick, although it does begin adding new events at different times depending on when the cache was last deleted (i think). I've used the Onyx program to do this and indeed it influences the start date for the creation of new events via your script, so I don't think it has anything to do with the master calendar. Since I repeatedly run this script to make new events and then export the calendar, delete it, make a new untitled calendar and then run the script again... I've found that iCal and the applescript sloooow down over time and it is best to quit both, maybe even restart and then start the process again. Guess I might never figure this one out.
    Thanks for the help,
    dan

  • Applescript ScriptUI or Flex (hesitations)

    Hi Guys,
    I wrote applescript scripts that my customer is happy with. We chose applescript as the script was aimed to work with QuarkXpress and Indesign on mac platforms.
    But as native applescript is quite limited in the interface area, they want to turn into Javascript extended abilities regarding to Interface Creation. I am ok with that. The only concern I have is that the Applescript codes were executing system operations such as zipping/unzipping, http connections (curl in a do shell script), remove files...
    I know you can execute applescript with javascript and doScript (in a mac environment of course) and I have to run some tests. However, as I want to dig with Flex as much as possible from now, I thought I could use it instead of ScriptUI.
    BUT whatever I use ScriptUI or Flex, I have no certitudes that they will do what I need them to do like I explained above. Do you have any feedback on this topic ? Is one of these technologies more appropriate ? Maybe none of these can do the trick ?
    Any advice would be welcome.
    Loic

    Hi and thanks a lot Shane and Harbs for your helpful answers,
    Ok, I have now great material and indications to dig further.
    One last thing Harbs, I was told Applescript studio project couldn't be ran from Indesign.
    http://macscripter.net/viewtopic.php?id=34296
    Because the main problem is that teh customer wants some widgets that standard Applescript can't offer (Dropdowns, checkbox...). So Applescript Studio looked like the solution but it seemed like it could be only used as an external software.
    Loic

  • Using Applescript to track Mail "Mark as Unread"

    Hi,
    I'm new to actionscript, I've never written anything using it. I'm a web developer, so I know JS, PHP and languages like that, but Applescript seems quite different to me.
    Anyways, I would like to know if it is possible to have a script in the background with an event handler that will trigger additional actions when a message is marked as unread?
    Pretty much, I want some code (that I will work out later) to be executed when a user marks a message as unread in Mail. ("Message"->"Mark"->"As Unread" OR ⇧⌘U)
    Thanks

    I'm new to actionscript
    You mean AppleScript, right?
    I would like to know if it is possible to have a script in the background with an event handler that will trigger additional actions when a message is marked as unread?
    Not directly. The ideal way of doing this would be for Mail.app to have some kind of option to attach AppleScripts to events within the application. It's entirely possible to do within the OS, but few applications take advantage of it - that includes Mail.app, so there's no way to have Mail.app call your script directly.
    The closest you could get would be a background script that silently polled Mail.app for the status of all messages and somehow detect when a message went from Read to Unread. This could be unwieldy, especially if there are many, many messages in the mailbox - you pretty much have to keep track of every read message and scan for any unread messages that are in the previous read messages list. This option doesn't work if you want to perform some real-time action such as interact with the user since there would always be some delay between the user action (marking the message unread) and the script noticing it.

  • How do I automatically quit an application?

    Hello,
    Can anyone tell me what the easiest way would be to have an program quit automatically on a schedule? For example, I need Application A to quit Monday to Friday at exactly 6pm.
    Thanks in advanced

    It's easy enough to write an Applescript to quit a running program. You can then use utilities such as Cron, Cronnix, etc. to schedule when the script will run.
    Look for other utilities at VersionTracker or MacUpdate. Perhaps you'll find something more suitable. For example, I found QuitApp++ on a quick search.

Maybe you are looking for

  • Computer crashed during update and now I can't access iTunes Store!

    Hi! I was going to update my iTunes to the latest version, but my computer crashed halfway through. Ever since then, I can't access the iTunes store! I don't know whether trying to update it again would fix the issue? Also, when choosing to update it

  • Small horizontal stripes on the display during turning it off on iPhone 3G

    I have used the iPhone 3G for two months now and today I have just noticed a quite strange problem on the display. If I turn the iPhone on there are no anomalities everything works great but if I turn it in Standby-Mode there are always some black ho

  • ABAP for HANA certification

    I am ABAP consultant having 9 years of exp. I want to do certification for ABAP for Hana.I found one certification with name SAP Certified Development Specialist - ABAP for SAP HANA (Edition 2014). In that i found below line written "This certificati

  • I need to know how to copy

    I need to know how to copy and paste on this IPad.Also I downloaded photos from the Mac onto my IPad and it said download complete, but could not find my photos.I don't have an icon for I Photo Library.The Apple store deleted all my apps,when they fi

  • Transition effects between the states..?

    Hi, There.    How I can set the "Transition effects" between the states please?. When I add the different photos to the several states, I want to set the transition effects like "Fade". Help me anyone please. Thanks