Home Forums OS X Server and Client Discussion Questions and Answers launchd to launch shell scripts

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #376574
    mosx86
    Participant

    I’ve written a shell script that I’d like launchd to periodically run. I’ve created the plist file for /Library/LaunchDaemons/ and loaded it with launchctl, and everything works just like it should except for one part.

    Basically, the script does a du on user homes and then is supposed to send me an email that contains a list of offending user homes and their disk usage.

    The bash script I’ve written works perfectly when run from terminal as my admin user, however when it’s launched via launchd, the body of the message is never attached and I simply get a blank message.

    /usr/bin/mail -s “Disk Usage $userType $serverHost” $fromAddress < /tmp/duPass2 duPass2 is being created and is readable to the script, and if I run the script as my admin user it goes off without a hitch, the only time there is a problem is when it's launched with launchd in which case I get an empty email. Am I missing something obvious?

    #378482
    Rusty Myers
    Participant

    is launchd running the command or a script with the command in it? I’d try a script with the command in it if your not doing that. Also, where are you putting the launchd plist? /Library/LaunchDaemons/ or /Library/LaunchAgents/ or other?

    #378534
    khiltd
    Participant

    launchd does not give you a full shell environment, so if any part of your script is dependent on any particular user’s environment variables, they need to be set in the job itself.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Comments are closed