launchd

launchd: Managing a Java Jar

蓝咒 提交于 2019-12-11 03:44:29
问题 I have the following launchd configuration (stored in acme.plist ) which I load and start using launchctl load acme.plist and launchctl start acme.plist respectively. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.acme</string> <key>ProgramArguments</key> <array> <string>/usr/bin/java</string> <string>-jar /usr/local/acme/acme-latest.jar<

Mac Launch Daemon unable to retrieve password from system keychain after saving it there

前提是你 提交于 2019-12-10 13:59:01
问题 We have a Launch Daemon which (necessarily, for various reasons) runs as root, and which communicates with a server component via the network. It needs to authenticate with the service, so when it first obtains the password, we save it to the system keychain. On subsequent launches, the idea is to retrieve the password from the keychain and use it to authenticate with the network service. This has been working fine, but on macOS 10.12 the existing code stopped working, and we've been entirely

launchd: sleep in GCD managed signal handler

那年仲夏 提交于 2019-12-10 11:39:34
问题 I encounter a strange situation in a launchd managed daemon when I try to sleep in the SIGTERM handler that is managed with Grand Central Dispatch as described here. Everything works fine and I do get a SIGTERM signal handler before receiving a SIGKILL when I do not sleep in the SIGTERM handler. But as soon as I do sleep -- even for extremly short amounts of time like a usleep(1); -- I do not get a SIGTERM handler at all but instead my daemon is SIGKILLed instantly by launchd. Btw I am using

Running a Shell Script on Shutdown via launchd

為{幸葍}努か 提交于 2019-12-10 10:39:21
问题 Since startup items and rc commands are both deprecated (and in many cases not working at all) on OS X in favour of launchd , I'd like to find out what the correct way would be to setup a shell script that runs on logout/shutdown. For a startup item it was possible to create a shell script that looked something like: #!/bin/sh StartService() { echo "Started." } StopService() { echo "Stopped." } RunService "$1" But the RunService command isn't supported when running a script from launchd , and

How can I add arguments to OSX launchd plist to pipe output to a log file?

最后都变了- 提交于 2019-12-09 07:36:26
问题 I have tried many different variation on this but just can't get it to work. I have a plist file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.ilium007.handbrake</string> <key>ProgramArguments</key> <array> <string>/bin/bash</string> <string>/Users/ilium007/support/scripts/handbrake/handbrake.sh >> /Users/ilium007/support/scripts/handbrake

How to know a specific launchd.plist file location?

流过昼夜 提交于 2019-12-09 04:41:13
问题 Is it possible to know the .plist file location which is loaded into the launchctl command? The label name is listed with "launchctl list" and its contents can be viewed by "launchctl list LABEL", but I cannot find the .plist file location. I know it will be located in /Library/LaunchAgent or ~/Library/LaunchAgent or something, but I don't want to search around paths while all jobs is listed with the launchctl command. 回答1: This issue comes up a lot and unfortunately locate and mdfind both

Launchd OSX not running bash with teamcity agent

梦想的初衷 提交于 2019-12-08 19:47:55
问题 I have a shell script startup.sh that does the following (create a RAM disk and start the teamcity agent): #!/bin/bash DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://16777216` /usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" $DISK /Users/administrator/buildAgent/bin/agent.sh start I can run this from the command line by typing ./startup.sh and it runs correctly. When I run from launchd, it ONLY creates the RAM disk, teamcity doesn't start. My launchd plist is located in ~/Library

Launchd job running every minute

心已入冬 提交于 2019-12-08 04:26:14
问题 I am attempting to write a launchd script that runs once a day, on weekdays only. But once I load the script, it runs every minute instead of just on-schedule. This happens whether I load the script as myself or as superuser: launchctl load ~/Library/LaunchAgents/org.myname.foojob or sudo launchctl load /Library/LaunchDaemons/org.myname.foojob This is the plist file: org.myname.foojob <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd

Is it possible to run pluginkit from a process running as root?

99封情书 提交于 2019-12-08 03:55:02
问题 I'm trying to run pluginkit (The executable that manages extensions on OS X) from a launch daemon running as root. /usr/bin/pluginkit -m -i "<identifier>" fails with an output of match: Connection invalid . This is not terribly unexpected, since extension settings are handled on a per-user basis. However, I've tried to use su to run pluginkit as a normal user, and it still doesn't work. su <username> -l -c "/usr/bin/pluginkit -m -i "<identifier>" also fails with an output of match: Connection

Mac : Launch command when device connected by bluetooth

别等时光非礼了梦想. 提交于 2019-12-08 01:59:54
问题 I would like to launch a shell command when a specific external bluetooth device is connected to my Mac. A nice way (without installing third party software) to do that is by adding a plist file in ~/Library/LaunchAgents On this page, there is an example of launching an event when the wifi connects to a specific location. It is done by watching a specific file : <key>WatchPaths</key> <array> <string>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist</string> </array>