lots of hung cron jobs

Mark Sapiro mark at msapiro.net
Wed Nov 6 17:44:50 UTC 2019


On 11/6/19 5:11 AM, Peter H. Lemieux wrote:
> I had the same situation this morning.  I've disabled the cron job for now.
> 
> Running "ms-cron HOURLY" from the command prompt hangs.
...
> Running "ps ax" on this server this morning brought up over a dozen hung
> cron processes like this:
> 
> awk -v progname=/etc/cron.hourly/mailscanner progname {?????   print
> prognam
> /bin/sh /usr/sbin/ms-cron HOURLY
> /bin/sh /usr/sbin/ms-check


/usr/sbin/ms-cron HOURLY will at most run two jobs depending on whether
or not they are enabled in /etc/MailScanner/defaults. the two jobs are
ms-check which will run if ms_cron_check=1 in /etc/MailScanner/defaults
and ms-msg-alert which will run if ms_cron_msg_alert=1 in
/etc/MailScanner/defaults.

By default, only ms-check is enabled and that is apparently what is hanging.

What ms-check does is check to see if MailScanner is running[1] and if
not and if it wasn't intentionally stopped[2], it attempts to kill any
stray MailScanner processes and then start MailScanner. The place where
it can hang is in this code:

>         # kill any rogue processes
>         kill -15 $(ps axww | grep '[M]ailScanner' | awk '{print $1}') > /dev/null 2>&1
>         # wait until they're gone.
>         while (ps axww | grep -q '[M]ailScanner'); do
>             sleep 1
>         done

That code should be OK. It says find the pids of any processes which `ps
axww` reports as having MailScanner in their names, send them a SIGTERM
and then wait until there aren't any more. There could be and issue if
they don't all die or if a new one starts while ms-check is waiting for
them to die. but under normal circumstances, MailScanner will be running
and ms-check will exit without doing any of this unless somehow the pid
in MailScanner's configured PIDFile is not the pid of the running
MailScanner.

In summary, I don't know why this is happening, but perhaps this info
will help.

[1] determined by the pid in MailScanner's configured PIDFile existing
and being a MailScanner process
[2] determined by the presence of /var/lock/subsys/MailScanner.off
-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan


More information about the MailScanner mailing list