plist - Mac run shell script startup -
i have plist file should start shell script on startup.
<?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.app.localclient</string> <key>program</key> <string>~/documents/local_client/server.sh</string> <key>runatload</key> <true/> <key>keepalive</key> <true/> </dict> </plist>
i've saved plist file com.app.localclient.plist
, have tested shell script works fine. when try load script launchctl load com.app.localclient.plist
, loads plist not start shell script. i've changed program parameter ~
/users/username/
, no succes. there way make plist start shell script , can done without knowing username of script saved (so using ~ in path).
maybe try running shell know $home:
<key>programarguments</key> <array> <string>bash</string> <string>-c</string> <string>"$home/documents/local_client/server.sh"</string> </array>
in order debug this, please try:
<key>programarguments</key> <array> <string>bash</string> <string>-c</string> <string>"echo hi > /tmp/debug.txt"</string> </array>
and see if /tmp/debug.txt
exists afterwards. if works, try making last string
"/usr/bin/whoami > /tmp/debug.txt"
and see in /tmp/debug.txt
Comments
Post a Comment