Home › Forums › OS X Server and Client Discussion › Questions and Answers › launchd executes plist twice instead of once?
- This topic has 2 replies, 2 voices, and was last updated 18 years, 10 months ago by
cshooshan.
-
AuthorPosts
-
June 11, 2006 at 1:45 am #366392
cshooshan
ParticipantHowdy!
I have cured my learn junk mail problem by adding a file called com.apple.learnjunkmail.plist to /System/Library/LaunchDaemons and loading it with launchctl.
The file includes the following keys:
Label
com.apple.learnjunkmailProgramArguments
array
string /etc/mail/spamassassin/learn_junk_mail
/arrayLowPriorityIO
trueNice
1StartCalendarInterval
Hour
integer 2
Minute
integer 15Now, I also modified the learn_junk_mail script to delete junkmail and reconstruct the junkmail mailbox, then email me a Success message.
These are the addtions to the end of /etc/mail/spamassassin/learn_junk_mail:
rm /var/spool/imap/user/junkmail/*. [greater ampersand] /dev/null
rm /var/spool/imap/user/notjunkmail/*. [greater ampersand] /dev/nullsudo -u cyrusimap /usr/bin/cyrus/bin/reconstruct -r -f user/junkmail [greater ampersand] /dev/null
sudo -u cyrusimap /usr/bin/cyrus/bin/reconstruct -r -f user/notjunkmail [greater ampersand] /dev/null
su – admin -c [doublequote] echo ‘The script learn_junk_mail ran successfully.’ | mail -s ‘Success’ [email protected] [doublequote]
The email message is supposed to show up at about 2:15 am when the script runs. It always does but ****** and here’s the question ******, about three days a week I get a duplicate message three seconds early (so that is one sent at 2:14:57 and one sent at 2:15:00).
It’s driving me crazy! Is the script really running twice? Is it a launchd bug? Is it a script interruption because of either the LowPriorityIO or the Nice keys in the plist? Or is it something else? Can I stop it from sending two messages?
Three notes:
1. I thought it might happen only following a day that the server (it is primarily a mail server) is rebooted or the mail is started and stopped. That is not the case.
2. I compared the full headers of both pieces of mail and they are identical except for the Message-Id and the three second time differences in times sent and received.
3. There really can’t be any other way that this script is actually running except through launchd — if I unload the plist, I get no email message.
I know this is a small matter but I would surely appreciated some feedback!
Thanks,
CharlieP.S. Feel free to use my mods — they seems to work great except for the double mail (and possibly double running of the script).
June 15, 2006 at 2:20 am #366414cshooshan
ParticipantThank you! That is reassuring. I’ll leave it alone and watch the occasional wacky behavior.
— Charlie
-
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed