Question
Duplicate notifications from MailerContrib for some, but not all users. Why?
[Detail not relevant to the solution removed in final update.]
Crontab:
7 0 * * * /var/www/twiki/tools/runmailnewsnotify 7 0 * * * /var/www/twiki/tools/runmailwebnotify
cat /var/www/twiki/tools/runmailnewsnotify #!/bin/bash cd /var/www//twiki && /usr/bin/perl -I bin tools/mailnotify -q -news '*'
cat /var/www/twiki/tools/runmailwebnotify #!/bin/bash cd /var/www//twiki && /usr/bin/perl -I bin tools/mailnotify -q '*'
Note: MailerContrib was updated to latest version 01-Apr-2008; no change.
Any clues would be appreciated...
Environment
--
TimotheLitt - 02 Apr 2008
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
Closing this question after more than 30 days due to inactivity. Please feel free to reopen if needed.
--
PeterThoeny - 11 May 2008
Well, I still could use some help - the problem is still there. I think I provided as much useful information as possible.
Is there a better place to ask?
--
TimotheLitt - 12 May 2008
This is the right place. You could add a pointer to this open question in the
MailerContribDev topic.
--
PeterThoeny - 13 May 2008
Try this: Please do not run both commands at the same time. According to your crontab, runmailwebnotify is invoked while runmailnewsnotify is
still running.
In otherwords, crontab should be one line:
7 0 * * * /var/www/twiki/tools/runmailnotify
And runmailnotify should be
#!/bin/bash /var/www/twiki/tools/runmailnewsnotify /var/www/twiki/tools/runmailwebnotify
Or even,
#!/bin/bash cd /var/www//twiki && /usr/bin/perl -I bin tools/mailnotify -q -news '*' cd /var/www//twiki && /usr/bin/perl -I bin tools/mailnotify -q '*'
--
GilbertHerschberger - 20 May 2008
Thanks for the hint!
This restriction wasn't obvious from the documentation - in fact, the installation instructions have a heading talking about "creating your cron job(
s)".
Seems like an interlock is missing in the code - shouldn't be the user's job to manage synchronization.
Here is the final resolution. I consolidated all the maintenance into a single cron job/script. This eliminated the duplicate notifications.
The script can be run several times a day if frequent notifications are desired; it will run weekly processing only once /wk and daily processing only once a day - on selectable day/time. (I run the old wrapper scripts for convenience when manually forcing an update; one could in-line them if desired.)
You might want to use this as an example in the documention or include it in the distribution. Nonetheless, the lack of synchronization seems like a bug.
crontab
# # Daily wiki maintenance - 0007 # -d debug, Day of week for weekly activities, hour for daily # 7 0 * * * /var/www/twiki/tools/twiki_maintenance Mon 00
twiki_maintenance
#!/bin/sh
#
# Run TWiki maintenance tasks sequentially
#
# Independent crontab entries may run in parallel
# and produce duplicate notifications per
# http://twiki.org/cgi-bin/view/Support/DuplicateNotificationsFromMailerCon
#
# One crontab entry runs this periodically
#
PG=`basename $0`
TOOLS=`dirname $0`
NOW=`date +"%a|%H"`
TODAY=`echo $NOW | sed -e 's/^\(.*\)|\(.*\)$/\1/'`
HR_NOW=`echo $NOW | sed -e 's/^\(.*\)|\(.*\)$/\2/'`
#
# -d = enable debug messages
#
if [ "$1" = "-d" ]; then
DEBUG='Y'
shift
fi
#
# $1 = Day of week (Mon ... Sun) to do weekly processing
#
WKLY_DAY=$1
#
if [ -z "$WKLY_DAY" ]; then WKLY_DAY="$TODAY" ; fi
#
# $2 = Hour (00-23) to do daily & weekly processing
# (Other hours do hourly only)
#
WKLY_HR=$2
if [ -z "$WKLY_HR" ]; then WKLY_HR="$HR_NOW" ; fi
#
# Output debug message
#
function Debug () {
if [ -n "$DEBUG" ]; then
echo "`date` [$PG] $*"
fi
}
#
#
#
Debug "Running on $TODAY @ $HR_NOW:xx"
#
# Stuff to do every day
#
if [ "$HR_NOW" -eq "$WKLY_HR" ]; then
#
# Daily at specified hour
#
Debug "Running statistics"
$TOOLS/runstatistics
if [ "$TODAY" = "$WKLY_DAY" ]; then
#
# Weekly processing
#
Debug "Running ticktwiki"
$TOOLS/runticktwiki
fi
fi
#
# Every hour that cron runs this script
#
Debug "Running newsnotify"
$TOOLS/runmailnewsnotify
Debug "Running webnotify"
$TOOLS/runmailwebnotify
# [End of file]
--
TimotheLitt - 14 Jul 2008
Making a lock may be a good idea but implemented the wrong way it a crash of code can mean that nothing will work again in a dead lock so who ever decides to make a lock must make it fool proof.
--
KennethLavrsen - 14 Jul 2008
Upgrading to new twki and realized that my example had hardcoded the tools directory. Updated to figure it out at runtime. Perhaps it will help someone else.
--
TimotheLitt - 14 Oct 2008