Difference between revisions of "Launchd"
From Wasya Wiki
(Created page with " == Startup Scripts == From: https://medium.com/@fahimhossain_16989/adding-startup-scripts-to-launch-daemon-on-mac-os-x-sierra-10-12-6-7e0318c74de1 Agent is run on behalf of...") |
(→Startup Scripts) |
||
| Line 25: | Line 25: | ||
<string>/usr/local/lib/mongodb/bin</string> | <string>/usr/local/lib/mongodb/bin</string> | ||
</array> | </array> | ||
| + | </dict> | ||
| + | </plist> | ||
| + | </pre> | ||
| + | |||
| + | Another example: | ||
| + | <pre> | ||
| + | <?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.piousbox.mysql</string> | ||
| + | <key>ProcessType</key> <string>Interactive</string> | ||
| + | <key>Disabled</key> <false/> | ||
| + | <key>RunAtLoad</key> <true/> | ||
| + | <key>KeepAlive</key> <true/> | ||
| + | <key>SessionCreate</key> <true/> | ||
| + | <key>LaunchOnlyOnce</key> <false/> | ||
| + | <key>ExitTimeOut</key> <integer>600</integer> | ||
| + | <key>Program</key> <string>/usr/local/mysql/bin/mysqld</string> | ||
| + | <key>WorkingDirectory</key> <string>/usr/local/mysql</string> | ||
</dict> | </dict> | ||
</plist> | </plist> | ||
Revision as of 20:27, 8 September 2018
Startup Scripts
Agent is run on behalf of the logged in user while a daemon runs on behalf of the root
/Library/LaunchAgents/com.mongodb.mongodb.plist
<?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.mongodb.mongodb</string> <!-- org.mongodb.mongodb perhaps? -->
<key>OnDemand</key>
<false/>
<key>Disabled</key>
<false />
<key>UserName</key>
<string>piousbox</string>
<key>GroupName</key>
<string>wheel</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/lib/mongodb/bin</string>
</array>
</dict>
</plist>
Another example:
<?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.piousbox.mysql</string>
<key>ProcessType</key> <string>Interactive</string>
<key>Disabled</key> <false/>
<key>RunAtLoad</key> <true/>
<key>KeepAlive</key> <true/>
<key>SessionCreate</key> <true/>
<key>LaunchOnlyOnce</key> <false/>
<key>ExitTimeOut</key> <integer>600</integer>
<key>Program</key> <string>/usr/local/mysql/bin/mysqld</string>
<key>WorkingDirectory</key> <string>/usr/local/mysql</string>
</dict>
</plist>
The -w flag makes it load always on startup.
sudo launchctl unload -w /Library/LaunchAgents/com.mongodb.mongodb.plist sudo launchctl load -w /Library/LaunchAgents/com.mongodb.mongodb.plist