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"
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
$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?