|
|
Easily run a script on login in the background
launchd would be the proper way to do this.
Easily run a script on login in the background
Any insights (your instructions, doc links, 'man' pages) into doing this through launchd?
RE: launchd
I don't think
You can follow the instructions over at Mac Geekery for another use of launchd items, but relevant to this disscussion are LaunchAgents.
So the general case will be to place a launchd item in the first directory, the user's LaunchAgents folder.
Creating the Script
If we want to run a script at login, one first has to save the script somewhere. I chose
and saved it as an executable file named HelloWorld in the above folder. Replace "YOURUSERHERE" with your short username (i.e. your home directory).
Creating the launchd Item
You can either use PropertyListEditor or any text editor to create the
After you've saved it, or if you're using a text editor, the file should look like:
Again, replace "YOURUSERHERE" with your short username (i.e. your home directory). Now you can test your LaunchAgent by opening Terminal and running launchctl load Library/LaunchAgents/com.example.userlogin.plist. You should see a HelloWorld.txt file on your Desktop. Delete it and as a final test log out and log in. You should see the file on your Desktop as you log in.
Problems
If your LaunchAgent isn't working, check Console and see if
You can add a key titled Debug with a boolean value that's false to your launchd item and run the test on the command-line. (You might need to unload the item first (e.g. launchctl unload ... before loading it again.) When you run it with the Debug value set to true, errors and output go to the command-line instead of to Console.
launchd Limitations
Now, as I said, I don't think that
RE: launchd
I have a LaunchDaemon that uses osascript with an applescript as its argument. This is to run an AppleScript to update a DNS server of my newly changed dynamic IP. This is stored in /Library/LaunchDaemons and runs regardless of a user being logged in. It is set to rerun every 15 minutes:
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.08 seconds |
|