Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

sending mail from launchd

Hi there,

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)

Posted on Jul 28, 2010 6:10 AM

Reply
Question marked as Best reply

Posted on Jul 28, 2010 7:06 AM

When launchd runs a script and the script is done running, launchd kills any processes trigger by the script unknowingly if they've completed or not.

You can add this directive to the launchd job plist and launchd will then not do that.

key>AbandonProcessGroup</key>
<true/>


That's likely the cause. If not, paste your launchd job plist.
2 replies
Question marked as Best reply

Jul 28, 2010 7:06 AM in response to costicladop

When launchd runs a script and the script is done running, launchd kills any processes trigger by the script unknowingly if they've completed or not.

You can add this directive to the launchd job plist and launchd will then not do that.

key>AbandonProcessGroup</key>
<true/>


That's likely the cause. If not, paste your launchd job plist.

sending mail from launchd

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.