Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Simple Script and Launchd error

Hi, I 'm just trying to run a simple script tu restart afp services over night, I have try so much things but my script just refuse to run, got error 127 and now just dont know what to do next to make it work. Thanks for your help.



My script Location: /script/afprestrat.sh

sudo chmod a+x /script/afprestrat.sh



The script:


#!/bin/bash

serveradmin stop afp

sleep 2

serveradmin start afp



PLIST location :

/Library/LaunchDaemons/com.compagny.afprestart.plist


the 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.compagny.afprestart</string>

<key>ProgramArguments</key>

<array>

<string>sh</string>

<string>/script/afprestart.sh</string>

</array>

<key>StandardErrorPath</key>

<string>/Users/admin/Documents/script/afprestart_err.log</string>

<key>StandardOutPath</key>

<string>/Users/admin/Documents/script/afprestart.log</string>

<key>StartCalendarInterval</key>

<dict>

<key>Hour</key>

<integer>4</integer>

<key>Minute</key>

<integer>05</integer>

</dict>

</dict>

</plist>


Command:

sudo launchctl load -w /Library/LaunchDaemons/com.compagny.afprestart.plist


Console error:


com.apple.launchd com.compagny.afprestart Exited with code:127

and afp service wasnt restart.


Any hint will be really apprciated.


thx !!!



Mac OS X (10.7.5), windows 2008 sr2

Posted on Feb 5, 2014 7:09 AM

Reply
16 replies

Feb 10, 2014 3:54 PM in response to Rich_ClickPom

I tried putting your details (without logs) into Lingon and it says it will not validate without the following empty keys:


<key>QueueDirectories</key>

and

<key>WatchPaths</key>


I don't understand why but you could try these 2 changes as shown below.



<?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>test-test</string>

<key>ProgramArguments</key>

<array>

<string>sh</string>

<string>/script/afprestart.sh</string>

</array>

<key>QueueDirectories</key>

<array/>

<key>StartCalendarInterval</key>

<dict>

<key>Hour</key>

<integer>4</integer>

<key>Minute</key>

<integer>5</integer>

</dict>

<key>WatchPaths</key>

<array/>

</dict>

</plist>

Feb 11, 2014 6:03 AM in response to Rich_ClickPom

But with the change we made I have now more info in the StandardErrorPath:


sh: /script/afprestart.sh: No such file or directory

sh: /script/afprestart.sh: No such file or directory

sh: /script/afprestart.sh: No such file or directory

/bin/bash: /script/afprestart.sh: No such file or directory

/bin/bash: /script/afprestart.sh: No such file or directory

/bin/bash: /script/afprestart.sh: No such file or directory

sh: /script/afprestart.sh: No such file or directory


Look like a filename error, there is a misstype caracter in my script name "script.afpretsart.sh" must be afprestart.sh . wiil give a try but I think this will works. Let know know tomorow.


Regards,

Feb 12, 2014 4:03 AM in response to Neville Hillyer

Ok now I got this:



-127com.compagny.afprestart

Ligne 2 and ligne 4 of the script command not found thats mean:


serveradmin: command not found


will try to add the full path of the serveradmin command in the script:


#!/bin/bash

/Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin stop afp

sleep 2

/Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin start afp



Any better idea ?


thanks !

Simple Script and Launchd error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.