I'm leaing to use launchd to auto-run some scripts. To make it simple, I decide to use a shell script which only contains a echo command.
hello.sh
#! /bin/sh
echo "hello"
Also I've run chmod a+x hello.sh to make it executable and when I run the script manually it works fine.
In ~/Library/LaunchAgents/ I have com.yang.hello.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.yang.hello</string>
<key>Program</key>
<string>/Users/yangyy/hello.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
After I run
launchctl load -w ~/Library/LaunchAgents/com.yang.hello.plist
no error message appears and there retus
- 78 com.yang.hello.plist
when I run launchctl list | grep "com.yang.hello"
It seems that positive number indicates the exit code and the program is not actually running.
Besides, I find something strange when I tried to use launchctl start ~/Library/LaunchAgents/com.yang.hello.plist to run the program, but when I use this command it retus error and no error message.
What's wrong?
Recent Questions...
ما را در سایت Recent Questions دنبال میکنید
برچسب:
نویسنده: استخدام کار
بازدید: 213
تاريخ: دوشنبه
7 تير
1395 ساعت: 9:32