sending mail from launchd
i have a script that checks SMART status and sends an email with results. This script used to work fine under previous versions of OS (through crontab) but seems to not work with launchd.
Script is executed as scheduled, i can see that all commands are executed but not the last one that sends the email.
here's my script:
#!/bin/bash
+current_date=`/bin/date %m%d%y`
+status0=`/usr/sbin/diskutil info disk0 | /usr/bin/grep SMART`+
+status1=`/usr/sbin/diskutil info disk1 | /usr/bin/grep SMART`+
+/bin/echo "SMART status for server:" > /tmp/SMART_today.txt+
+/bin/echo "hdd1 " $status0 >> /tmp/SMART_today.txt+
+/bin/echo "hdd2 " $status1 >> /tmp/SMART_today.txt+
+email_subject="server2 SMART status"+
+/bin/echo $email_subject >> /var/log/system.log+
+/bin/cat /tmp/SMART_today.txt | /usr/bin/mail -s '$email_subject' user@domain.com -r user@domain.com+
exit
While troubleshooting this i was able to narrow it down to the mail command, which for whatever reason is not completed.
Under launchd, this is setup to run as a user daemon running as root. Manually running this script under root account works just fine
Can anybody help with this? 🙂
MacBook Pro; 24" iMac, Mac OS X (10.6.2)