In OSX 10.6 I'm running logcheck.sh via. launchd using this plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>org.logcheck</string>
<key>Program</key><string>/opt/local/bin/logcheck.sh</string>
<key>StartInterval</key><integer>600</integer>
</dict>
</plist>
logcheck runs at the specified interval but it won't send me mail using the command below:
cat $TMPDIR/checkreport.$$ | $MAIL -s "$HOSTNAME $DATE system check" $SYSADMIN
where
$TMPDIR=/opt/local/var/tmp
$MAIL=/usr/bin/mail
$SYSADMIN=myuser
however, if I hack it, and change the command to:
cat $TMPDIR/checkreport.$$ > /Users/myuser/report
cat /Users/myuser/report | $MAIL -s "$HOSTNAME $DATE system check" $SYSADMIN
then I receive the mail.
Checking permission on tmp with $ls -l /opt/local/var
I get
drwx------ 20 root admin 680 Jul 12 13:29 tmp/
If I run sudo /opt/local/bin/logcheck.sh
the first command works.
If I use /opt/local/bin/logcheck.sh
in root's crontab the first command works.
If I throw in the script echo "$(whoami)" > /Users/myuser/launchduser
I see that it is indeed being run by root.
Why am I not getting mail with the first command in launchd? Is it a permissions issue with the pipe to mail?