launchd

How to access environment variables in launchd plist

空扰寡人 提交于 2021-02-18 22:10:54
问题 I have a launchd per-user agent. In it's .plist, I would like to use the $HOME environment variable. Is it possible? (it is the "Program" key, which I would like to define as "$HOME/bin/myscript") 回答1: launchd doesn't perform any substitutions on the values in its .plists, so this can't be done in the form you're trying to do it. What you can do is hand the command you want to run to a shell, and let it perform the variable substitutions and run the command. For instance, you could replace

launchd.plist runs every 10 seconds instead of just once

℡╲_俬逩灬. 提交于 2021-02-18 11:30:10
问题 I have been setting up a launchd.plist XML that is run every time a specific USB device is mounted. I followed the instructions on the xpc_events(3) man page and it is running the application whenever the device is mounted. The problem I'm having is that the application is run again and again every 10 seconds as long as the device is still mounted. How can I set it up so it only runs once when the device is inserted in the USB port? <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist

launchd plist with large StartInterval never runs

烂漫一生 提交于 2021-01-29 20:13:20
问题 I'm trying to run a command once per day like so: <?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>local.borgmatic</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/borgmatic</string> <string>--syslog-verbosity</string> <string>1</string> </array> <key>EnvironmentVariables</key> <dict> <key>HOME</key> <string>/Users/mike</string>

launchd plist with large StartInterval never runs

元气小坏坏 提交于 2021-01-29 16:12:05
问题 I'm trying to run a command once per day like so: <?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>local.borgmatic</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/borgmatic</string> <string>--syslog-verbosity</string> <string>1</string> </array> <key>EnvironmentVariables</key> <dict> <key>HOME</key> <string>/Users/mike</string>

MacOS Catalina launchd can't open input file error

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 12:31:49
问题 Why won't launchd load my zsh program? I'm befuddled. My testplisterror.log gives me this error: /bin/zsh: can't open input file: /Users/controlroom/Desktop/Bin/testplist.zsh -- below is my com.testplist.plist file located in the LaunchAgents directory. <?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.testplist.plist</string> <key

OS X launchd.plist

隐身守侯 提交于 2021-01-28 14:02:16
问题 Here's my plist file <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd > <plist version="1.0"> <dict> <key>Label</key> <string>com.homebrew.autoupdate</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/brew_up</string> </array> <key>StartInterval</key> <integer>86400</integer> <key>StandardErrorPath</key> <string>/usr/local/var/log/brew.log</string> <key>StandardOutPath</key>

Get launchd to run task when network connects or reconnects

本小妞迷上赌 提交于 2020-08-20 12:23:30
问题 I run a custom python script to update various dynamic DNS servers through launchctl and it runs every 15 minutes. This is both overkill and underkill. It would be nice if the script would execute only when reachability changes, and then as a fallback maybe every 30 minutes. I could easily enough update the Python script to check if the external address has changed before calling the update, but if my connection goes down and comes back up with a different IP address, I wouldn't want to have

Converting cron to launchd - MAILTO

爱⌒轻易说出口 提交于 2020-01-23 01:26:25
问题 Migrating from an old mac to a new one. Trying to migrate the user crontab I had on the old mac. Now I know I can probably get cron to run by creating /etc/crontab - but given that apple has deprecated it in favour of launchd - I thought I'd take a swing at migrating my crontab to launchd plist files. Always fun to learn something new :) The crontab isn't that hard - I tend to set up shell scripts that do the work and then just call them at scheduled times. I can call these fine from the

MAC OSX Agents - how to launch multiple instances

帅比萌擦擦* 提交于 2020-01-15 17:54:12
问题 I am trying to create helper objects (it could be a daemon or an agent). This should be launch on demand and its multiple instances should be there, as you see for Chrome and Safari helpers. What Have I tried? I have referred these Apple Docs, Launchd Tutorial & Creating Start Up Items in Mac OS X There it is mentioned that for number of processes we should use NumberOfProcesses key, I used it but in Activity Monitor I see only one instance. And my plist looks like this <?xml version="1.0"

MAC OSX Agents - how to launch multiple instances

▼魔方 西西 提交于 2020-01-15 17:49:30
问题 I am trying to create helper objects (it could be a daemon or an agent). This should be launch on demand and its multiple instances should be there, as you see for Chrome and Safari helpers. What Have I tried? I have referred these Apple Docs, Launchd Tutorial & Creating Start Up Items in Mac OS X There it is mentioned that for number of processes we should use NumberOfProcesses key, I used it but in Activity Monitor I see only one instance. And my plist looks like this <?xml version="1.0"