launchd

How can I launch multiple instances of an application using launchd?

My application is split into two parts. The main application and a helper tool. The helper tool performs a task with elevated permissions. The launchd plist looks like this: (Only important settings included.) <key>UserName</key> <string>root</string> <key>ProgramArguments</key> <array> <string>/Library/PrivilegedHelperTools/helper...

MacPorts Apache2 Stopped Launching on Boot

Something that I've noticed recently on two different machines is that Apache2 installed via MacPorts seems to have stopped launching when I boot up. The honest truth is that I can't swear it did so before, but it's something I think I'd notice because installing the LaunchDaemon is part of my install process. In fact, if I try to reload...

Run a cron job every x minutes with startCalendarInterval & launchd?

I'm using mac osx 10.6 - and it seems that the minutes parameter determines how many minutes past the hour that the job runs. But how do you set up a job to run ever x minutes past the hour. I've tried setting up minutes as an array of several numbers and an array with one string which is "*/5" i.e. similar to every five minutes syntax...

How to replace launchd scheduling with a Python program

The Mac OS X system startup program launchd enables job scheduling (similar to cron.) By creating a launchd agent, one can trigger programs through one of the following events: an interval of time has elapsed a certain calendar date has come a file path has been modified something has been placed in a certain directory (queue directory...

Spawn a screen session from launch daemon

I've written a launchd .plist which should attach a debugger to the WindowServer when it launches. The main part of the script looks like screen -D -m -S "WindowServer Debugger" \ gdb \ -x $GDBSCRIPT \ /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/WindowServer ...

Launchd agent not starting

I'm attempting to write a launchd agent that runs a simple application for every user that logs in to the Mac OS X system. I have created a file named com.mycompany.myapp.plist and placed it in /Library/LaunchAgents. The contents of that file are: { LimitLoadToSessionType = "Aqua"; StartInterval = 10; OnDemand = NO; Kee...

launch agent from daemon in user context

I have a launch daemon that runs in the login context of a Mac OSX 10.6 machine. I want to launch an agent for each user from that agent, and have the agent run in the user's login context. However, I need to control the precise arguments to the agent application very carefully, which is why I cannot use a launchd agent, like I have for ...

setenv variable with spaces in launchd.conf ?!

I'm a Linux user that just recently got a mac. I'm trying to set up my IDE and found out that Macs don't use .bashrc / .bash_profile / etc. for GUI apps. So, if you have a GUI app that needs an environment variable, you're apparently supposed to do it in /etc/launchd.conf The thing is, this file uses csh style setenv syntax ("setenv key...

Is it possible to filter users from a launchd plist?

I have some launchd plists that are now placed at the administrator per-user level, particularly inside: - /Library/LaunchAgents OR - /Library/LaunchDaemons I'd like to avoid that some of those services could start only for one user (possibly avoiding to move all the plists to ~/Library/LaunchAgents), which is the simplest way? Thanks ...

Get StandardErrorPath from within the process in OS X 10.6

Is there a way to get the standard error/output path from within the process? I tried NSTask's standardError but it returns NSFileHandle, and I need the path as string. Thank you! p.s. StandardErrorPath is set in a .plist used by launchd to start the process on system start. The process is a bundle, written in objective c. ...

Leopard/Snow Leopard, have to implement daytime server by using daemon?

Hi all, I find there is no daytime server available in leopard/snow leopard. And after reading some documents, the approach I can think of is writing a daemon and put it under /System/Library/LaunchDaemons, so that launchd can run it. I wonder if there is a way to just enable the service rather than writing a new one myself? Thanks in...

A way to enable a LaunchDaemon to output sound?

I have a small Foundation application that checks a website and plays a sound if it sees a certain value. This application successfully plays a sound when I run it as my user from the Terminal. I've configured this app to run as a LaunchDaemon, with the following plist: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//...

User agent or daemon?

I am writing driver to a HID device. The driver opens HID device in exclusive access mode. This driver should run for all user. So it should be either User agent or daemon. In driver I use some CoreGraphics API's which is under ApplicationService framework but Technote say's daemon won't get access to ApplicationService framework. So...

iPhone app crashes when launched from Xcode, but not from iPhone

I have an app that is crashing on the iPhone, but only when it launched via Xcode. I can see in the iPhone console log that the app receives a memory warning, and then there are some strange events like these: Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplicat...

Launchd.plist with WatchPaths key: How to set a minimum interval?

How would one set a minimum interval for a launchd.plist script with a WatchPath key? For example, I want to run a script every time new files appear in a directory, but I would like it to only run once an hour at maximum. The launchd.plist might look something like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "...

What's the difference between 'Day' and 'Weekday' in launchd StartCalendarInterval?

I'm working with launchd to run some automated tasks, and I was wondering what the difference is between 'Day' and 'Weekday'. According to http://discussions.apple.com/thread.jspa?threadID=1361809 there is a 'subtle' difference that can cause launchd to misbehave. Ultimately, I'd like to have a plist that runs every weekday (Mon - Fri...

what's the best way to get etherpad to launch on startup on OSX

I think launchd is the answer, but using this plist: http://gist.github.com/553573 I get this error: Exception in thread "main" java.lang.NoClassDefFoundError: net/appjet/oui/main Caused by: java.lang.ClassNotFoundException: net.appjet.oui.main at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessCo...

mac os x 10.6.4 launchd cron job stops after 2 days

I have a mac mini os x 10.6.4 which I use to host a web app for private use only. For certain functionality I needed a cron job so i used lingon (http://lingon.sourceforge.net/) to setup a launchd cron job - this creates a plist file in the following folder /library/launchDeamons folder. the job it self is just "curl -s localhost/api?met...

How does one get precise start times out of launchd like you can out of cron?

On an OS X 10.6 system I am trying to use StartCalendarInterval in launchd to replicate a cron job that runs on the 5 minute marks of the hour. (It is important in my application to start when requested and not merely start again five minutes after the previous invocation.) I find that the actual start time of the job varies considerably...

LaunchDaemon Plist not running

Hi Everyone I have created a plist file to launch my app (10.5 & 10.6)on the login screen, die when logging in and the respawn when the Desktop is loaded. If i place my plist file within /Library/LaunchAgents it runs correctly. If i try running it from /Library/LaunchDaemons it does not run. As this is my first app for the Mac i am uns...