diff options
-rw-r--r-- | cron | 7 | ||||
-rw-r--r-- | depends | 1 | ||||
-rwxr-xr-x | rhautoimport | 40 |
3 files changed, 30 insertions, 18 deletions
@@ -0,0 +1,7 @@ +# +# cron.d/rhautoimport -- scripts to import re-broadcasts +# +############## +# <show title> +27 18,19,20 * * 1-5 autoimport /usr/bin/rhautoimport-<code> +27 21 * * 1-5 autoimport /usr/bin/rhautoimport-<code> last @@ -6,3 +6,4 @@ liburi-perl libwww-perl libxml-feed-perl perl +util-linux diff --git a/rhautoimport b/rhautoimport index 2518231..7ae49ee 100755 --- a/rhautoimport +++ b/rhautoimport @@ -61,24 +61,28 @@ if [ -z "$MAIL_TO" ]; then MAIL_TO="root" fi -/usr/bin/rhautoimport-$1 ${@:2} > $LOG_FILE 2>&1 -case $? in - 0) - mail -a "Content-Type: text/plain; charset=utf-8" -s "$TITLE - Imported Successfully" $MAIL_TO < $LOG_FILE - ;; - 42) - # do nothing - the script didn't import anything but no message should be sent - ;; - *) - if [ "$2" == 'last' ]; then - subject="$TITLE - Import Error - last attempt!!!" - else - subject="$TITLE - Import Error - will retry" - fi - mail -a "Content-Type: text/plain; charset=utf-8" -s "$subject" $MAIL_TO < $LOG_FILE - ;; -esac +( + /usr/bin/flock -x -w 10 200 + + /usr/bin/rhautoimport-$1 ${@:2} > $LOG_FILE 2>&1 + case $? in + 0) + mail -a "Content-Type: text/plain; charset=utf-8" -s "$TITLE - Imported Successfully" $MAIL_TO < $LOG_FILE + ;; + 42) + # do nothing - the script didn't import anything but no message should be sent + ;; + *) + if [ "$2" == 'last' ]; then + subject="$TITLE - Import Error - last attempt!!!" + else + subject="$TITLE - Import Error - will retry" + fi + mail -a "Content-Type: text/plain; charset=utf-8" -s "$subject" $MAIL_TO < $LOG_FILE + ;; + esac + rm -f $LOG_FILE -rm -f $LOG_FILE +) 200>/var/lock/rhautoimport-$1.lock exit 0 |