1

Topic: sa-update.cron hangs

==== Required information ====
- iRedMail version: 0.8.3
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MYSQL
- Linux/BSD distribution name and version: CentOS 6.3
- Related log if you're reporting an issue:
====

Greetings community smile

Got my self an odd issue with sa-update.cron !

If I run manually
#> sa-update -D

everything works smooth !


The problem starts in /etc/cron.d/sa-update

10 4 * * * root /usr/share/spamassassin/sa-update.cron 2>&1 | tee -a /var/log/sa-update.log

... executing this sa-update with:

sh -x /usr/share/spamassassin/sa-update.cron

the script code line .....  "sleep $(expr $RANDOM % 7200)" hangs here !

Found this https://bugzilla.redhat.com/show_bug.cgi?id=561568

IF you comment this line to remove the delay ... the sa-update.cron output shows me:

(...)
+ /sbin/service spamassassin condrestart
+ '[' -f /etc/init.d/amavisd ']'
+ /sbin/service amavisd condrestart
The amavisd daemon is not running
+ '[' -f /var/run/mimedefang.pid

then I checked ...

#> ps -ef | grep amavis

amavis    1373     1  0 Nov17 ?        00:00:03 amavisd (master)
amavis    1490  1373  0 Nov17 ?        00:00:17 amavisd (ch18-avail)
amavis    5100  1373  0 09:30 ?        00:00:00 amavisd (ch1-avail)
root      6529  6452  0 17:47 pts/0    00:00:00 grep amavis

It was running already !!

Does anyone experiencing this issue in sa-update.cron !?

All comments and ideas are welcome smile
Thanks.

2

Re: sa-update.cron hangs

Looks like caused by this line "sleep $(expr $RANDOM % 7200)".
$RANDOM will return a integer number larger than 10000 and smaller than 99999, so the sleep seconds will be between 1 second (10000 % 7200) and 6399 seconds. If it's too long, it looks like "hangs", but it doesn't.
Try hard-coding sleep seconds to avoid "hangs". For example, replace it by "sleep 60" to sleep 1 minute, or "sleep 3600" to sleep 1 hour.

3

Re: sa-update.cron hangs

Thanks for the solution ... but still:

IF you comment this line to remove the delay ... the sa-update.cron output shows me:

(...)
+ '[' 0 -eq 0 ']'
+ /sbin/service spamassassin condrestart
+ '[' -f /etc/init.d/amavisd ']'
+ /sbin/service amavisd condrestart
The amavisd daemon is not running
+ '[' -f /var/run/mimedefang.pid ']'


then I checked ...

#> ps -ef | grep amavis
amavis    1373     1  0 Nov17 ?        00:00:03 amavisd (master)
amavis    1490  1373  0 Nov17 ?        00:00:17 amavisd (ch18-avail)
amavis    5100  1373  0 09:30 ?        00:00:00 amavisd (ch1-avail)
root      6529  6452  0 17:47 pts/0    00:00:00 grep amavis

Why it outputs me " The amavisd daemon is not running " ... if it is ON ?!

4

Re: sa-update.cron hangs

digitalbit wrote:

+ /sbin/service amavisd condrestart

Make sure above command can correctly detect Amavisd service status first.

Works fine for me here (CentOS 6.3, x86_64):

# /etc/init.d/amavisd condrestart
Shutting down amavisd: Daemon [1250] terminated by SIGTERM
                                                           [  OK  ]
amavisd stopped
Starting amavisd:                                          [  OK  ]

# echo $?
0

Executing /etc/cron.d/sa-update manually looks fine:

...
+ '[' 0 -eq 0 ']'
+ /sbin/service spamassassin condrestart
+ '[' -f /etc/init.d/amavisd ']'
+ /sbin/service amavisd condrestart
+ '[' -f /var/run/mimedefang.pid ']'

5

Re: sa-update.cron hangs

Thanks again for the support !

#> /etc/init.d/amavisd status

amavisd (pid 13880 13775 1373) is running...



#> ps -ef | grep amavisd

amavis    1373     1  0 Nov17 ?        00:00:05 amavisd (master)
amavis   13775  1373  0 14:49 ?        00:00:07 amavisd (ch13-avail)
amavis   13880  1373  0 14:54 ?        00:00:06 amavisd (ch10-avail)



#> /etc/init.d/amavisd condrestart

Shutting down amavisd: The amavisd daemon is not running      [FAILED]

Starting amavisd:    [  OK  ]



.... if I retype the command "/etc/init.d/amavisd condrestart" again the output fails again "Shutting down amavisd: The amavisd daemon is not running" sad

Got no idea why this is happening !
Any tip/debug please !!

6

Re: sa-update.cron hangs

Hi ZhangHuangbin !


Got this workaround for now ...


Replace this line:
/sbin/pidof $daemon >& /dev/null


with this:
/usr/bin/pgrep $daemon >& /dev/null


and this line:

sleep $(expr $RANDOM % 7200)

with this:

sleep $(expr $RANDOM % 60)


Let me check the next days behave!
Any better ideas ?!

7

Re: sa-update.cron hangs

Hi ZhangHuangbin !

You can close this post !
The problem was on the webpy (old version), with the new update of python-webpy-0.37-2.el6.noarch and his new dependency:  python-cherrypy-3.2.2-3.el6.noarch this problem got solved (rebooting the related services: iredapd, amavisd ... etc)

Thanks for the support

8

Re: sa-update.cron hangs

Weird.  Amavisd + SpamAssassin are written in Perl, they don't use either web.py and cherrypy at all.

9

Re: sa-update.cron hangs

I am having this same issue.  What was the fix?

digitalbit wrote:

Hi ZhangHuangbin !

You can close this post !
The problem was on the webpy (old version), with the new update of python-webpy-0.37-2.el6.noarch and his new dependency:  python-cherrypy-3.2.2-3.el6.noarch this problem got solved (rebooting the related services: iredapd, amavisd ... etc)

Thanks for the support

10

Re: sa-update.cron hangs

Hi rdarden,

Please create a new forum topic and clearly explain your issue, do not hijack other's topic.