2017-02-02 2 views
0

現在、plistを使用してシェルスクリプトを実行しています。launchd 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.name.set</string> 
       <key>Program</key> 
       <string>/Users/username_here/Desktop/simple.sh</string> 
       <key>RunAtLoad</key> 
       <true/> 
       <key>StartInterval</key> 
       <integer>5</integer> 
       <key>StandardErrorPath</key> 
       <string>/tmp/com.name.example.stderr</string> 
       <key>StandardOutPath</key> 
       <string>/tmp/com.name.example.stdout</string> 
     </dict> 
     </plist> 

これは機能します。しかし、プログラム名を

<string>/Desktop/simple.sh</string> 

に変更すると、スクリプトは実行されません。 ~/Desktop/simple.shも機能しません。

ユーザ名を知らずに絶対パスを使用してスクリプトを実行する方法はありますか?

私がtaildしたときにもこのエラーメッセージが表示されます。

com.apple.xpc.launchd[1] (com.name.example[8178]): Service could not initialize: 14F27: xpcproxy + 13421 [1402][AD0301C4-D364-31CE-8BA7-B5DBECE64D0A]: 0x2 

ありがとうございます!

答えて

0

デーモンがユーザーごとのエージェント(〜/ Library/LaunchAgentにインストールされている)として実行されている場合は、ピリオドを使用して相対パスを取得できます。これはあなたがこれを行うことができ、ホームフォルダ(~/

次のようになります。

<key>Program</key> 
<string>./Desktop/simple.sh</string> 

次のあなたのplistにあなたのプログラムを保存するために、よりよいかもしれません:

./Library/LaunchAgents/simple.sh