mac os x启动完成后启动一个守护进程

时间:2015-01-07 12:33:36

标签: macos

我正在使用这个plist:

<?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.test</string>
    <key>ProgramArguments</key>
        <array>
            <string>/Users/hzorha/Downloads/trunk/build/g5/macos/src/bin/g5/test</string>
        </array>
    <key>RunAtLoad</key>
        <true/>
    <key>KeepAlive</key>
        <true/>
</dict>
</plist>

test是二进制文件的名称。

我已将其放入/Library/LaunchDaemons/com.test.plist

我做错了什么,因为它在计算机启动时无法启动。

1 个答案:

答案 0 :(得分:1)

来自launchctlload子命令的unload手册页:

Load the specified configuration files or directories of configuration
files.  Jobs that are not on-demand will be started as soon as possible. All
specified jobs will be loaded before any of them are allowed to start. Note
that per-user configuration files (LaunchAgents) must be owned by root (if
they are located in /Library/LaunchAgents) or the user loading them (if they
are located in $HOME/Library/LaunchAgents).  All system-wide daemons
(LaunchDaemons) must be owned by root. Configuration files must disallow
group and world writes. These restrictions are in place for security rea-
sons, as allowing writability to a launchd configuration file allows one to
specify which executable will be launched.

Note that allowing non-root write access to the
/System/Library/LaunchDaemons directory WILL render your system unbootable.