Creating a Launch Daemon plist to run at startup

(running OSX 10.6.4 MacBook)

Hi All
I am just messing around and wanted to see if I could create a LaunchDaemon that would load on system start up and I seem to be doing something wrong.

I used Lingo to help me create a plist.
I was able to load the plist in to /Library/LaunchAgent/ and the plist ran when I logged in. The plist would not run on system startup, even though the plist does indicate to load on start up: "<key>RunAtLoad</key> <true/>"

I then moved the file to /Library/LaunchDaemon/. The plist is set to root:wheel permissions but it will not load on system startup nor on when I login.

I use launchctl in terminal to see what is running.
If I load the plist through launchctl, the plist will run and work just fine. However the point is to get it to load at system startup.

Any ideas? I am sure I am doing something wrong.

I have the plist at the bottom of this post.
The plist is pointing to a small script which just puts the date in to a file so I can see how often and when the plist was loaded and ran. Everything is included at the bottom.

PLIST START:
<?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.kaa.imageremover-hourly</string>
<key>ProgramArguments</key>
<array>
<string>/Users/MyUser/Desktop/script1.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>1</integer>
</dict>
</plist>
PLIST END
-------------------------------------------
SCRIPT START:
#!/bin/sh
echo "files removed at" >> /Users/MyUSER/Desktop/testfile.txt
date >> /Users/MyUSER/Desktop/testfile.txt
echo " " >> /Users/MyUSER/Desktop/testfile.txt

SCRIPT END

iMac / MacPro/ MacBook Pro / MacBook / OS X Server, Mac OS X (10.6.4), Experience with Active Directory OUs/GPOs, Windows 2003/XP

Posted on Feb 9, 2011 3:31 PM

Reply
7 replies

Feb 9, 2011 10:39 PM in response to Linc Davis

Hi Linc
I completely agree with you, I do want a LaunchDaemon not an Agent.
Unfortunately it does not seem that the plist runs when I loaded in to /Library/LaunchDaemon/ folder. There is nothing special about the plist, its very simple. I am not calling another Daemon nor am I calling a fork. Not sure why this simple plist will not run at startup.

I am going to do some more testing and reading. If I find an answer I will post it.

If anyone reads through my post, looks at my plist and finds what I did wrong, don't hesitate to let me know.
Cheers.

Feb 9, 2011 11:19 PM in response to rareapple

I was using Lingo 2.1 to create the previously mentioned plist; which did not workout.
I downloaded Lingon 1.2 and created this new plist which did work as it should have.
Here is the new plist which does work.

START 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.test2</string>
<key>ProgramArguments</key>
<array>
<string>/Users/MyUser/Desktop/script1.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>1</integer>
</dict>
</plist>
END PLIST

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Creating a Launch Daemon plist to run at startup

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