Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As a continuation from my initial question...

Routinely backup log file in OSX?

I'm attempting to backup a logfile on an OSX computer and a jailbroken iPhone. LaunchD was recommended as a solution and some Google searches later revealed LingOn to be the tool to use.

The output (after me filling the fields) gives me this 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.ash.MySuperLaunchd</string>
    <key>ProgramArguments</key>
    <array>
        <string>python</string>
        <string>/Users/ash/Desktop/sendemail.py</string>
    </array>
    <key>StartInterval</key>
    <integer>3600</integer>
</dict>
</plist>

Now running my python script by invoking it in the terminal will successfully send the email to my inbox with the attachments I need.

LaunchD just doesn't launch though and I'm not sure why.

share|improve this question
1  
Have you registered your plist with launchctl? Where did you put this file? –  Daniel Beck Jul 2 '11 at 10:36
    
Lingon puts the plist in /Library/LaunchDaemons/ –  Ash Jul 2 '11 at 11:32
    
I also registered with sudo launchctl load w- com.ash.MySuperLaunchd –  Ash Jul 2 '11 at 11:39
1  
I thin you need to load the file path, not the arbitrary identifier you assign, at least the man page looks like that. Also, I recommend you make the script file executable, add a shebang header specifying the path to which python and execute it directly to circumvent PATH issues. Lastly, check /Applications/Utilities/Console.app for error messages. –  Daniel Beck Jul 2 '11 at 12:18
1  
I double checked the shebang header and it was not pointing to the right directory. My fault as I copy and pasted a script that was made for Linux. Everything is now working, only I do not know how to replicate this on the iPhone. –  Ash Jul 2 '11 at 15:00

1 Answer 1

You need to load the agent. Either relogin, or launchctl load /path/to/file.plist.

RunAtLoad is false by default, so the script is run for the first time StartInterval seconds after it's loaded, in this case 3600.

The path in ProgramArguments needs to point to the permanent location of the script, so it probably shouldn't be at ~/Desktop/. The target script doesn't need to be executable. But as correctly troubleshot by @DanielBeck in the comments, check that you're able to for example python /Users/ash/Desktop/sendemail.py in the first place and that the shebang line is correct.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.