Re: cron problem

From: Maxim Kovgan (maxim.kvg_at_nonexisting.hamakor.org.il)
Date: Tue 24 Jan 2006 - 10:14:41 IST


Hi Shlomo.
I think it is rather useless to use "mail" binary in the cronjobs,
since cron uses it anyway.
the only thing you really need to do is to write something onto the
stdout from a cron job's script. namely, the date, and scripts name.
add:
echo "$0 started at `/bin/date`"
to the start of the script, and:
echo "$0 finished at `/bin/date`"
This will really suffice, the advantage of this is tremendous:
On the email you get, you will have delievery related timestamp. so
you will know if the mail is coming late or the cron script is running
late.
Sometimes email is processed not immediately, and this is something
you haven't taken into the account in your attempts.

Best regards,
Max.

On 1/23/06, Shlomo Solomon <shlomo.solomon_at_gmail.com> wrote:
> Hi again
>
> I did a clean install of Mandriva2006 on my machine and although, on the
> whole, it went well, I have had a few minor problems. Although I solved most
> of them, there are still a few that I can't seem to solve.
>
> Here is one such problem:
>
> In cron.hourly there are 5 jobs. None of them are **heavy**, but cron seems to
> finish only after 50 minutes.
>
> cron.hourly runs at 1 minute past the hour. Here's the relevant line
> from /etc/crontab:
>
> # run-parts
> 01 * * * * root nice -n 19 run-parts /etc/cron.hourly
>
>
> Here are the jobs in cron.hourly (I added the first and last for testing):
>
> [solomon_at_shlomo1 ~]$ ls -la /etc/cron.hourly
> total 49
> drwxr-xr-x 2 root root 328 Jan 23 19:58 ./
> drwxr-xr-x 244 root root 17384 Jan 23 19:35 ../
> -rwxrwxr-x 1 root root 296 Jan 23 19:53 aaaa-test-hourly*
> -rwxr-xr-x 1 root root 279 Jan 23 19:56 hylafax*
> lrwxrwxrwx 1 root root 14 Jan 13 14:46 msec -> /usr/sbin/msec*
> -rwxr-xr-x 1 root root 324 Jan 23 19:57 sysstat*
> lrwxrwxrwx 1 root root 27 Jan 19 22:26 zz-myechotest
> -> /data1/myscripts/myechotest*
>
> I added "debugging code" similar to the following to the end of each of the
> above scripts:
>
> ## first we test echo
> echo " this script is " $0
> echo "**** this is a test of the echo command in a CRON job ****"
>
> ## now mail to solomon
> echo "hylafax-hourly is mailing to solomon" | mail -s "hylafax-hourly solomon"
> solomon
>
> At 1 mnute past the hour, I get 5 e-mails (one from each of the above jobs),
> but only at 51 minutes past the hour, I get an e-mail from cron itself
> including the output of the 5 echo lines.
>
> Note that the "debugging code" is at the end of each script, so I assume that
> should rule out the possibility that one of the jobs is actually running for
> 50 minutes. I also looked at the output of ps -A and top and didn't see
> anything unusual.
>
> According to the mail log in /var/log/mail/info, 5 e-mails are being sent at
> 1 minute past the hour and 1 is being sent at 51 minutes past the hour (just
> as I'm receiving them). For readability, I marked each of the 6 e-mails in
> the log with ----->, but nothing else was changed.
>
>
> ----->Jan 23 20:01:00 shlomo1 postfix/pickup[25600]: 56BED8ECD: uid=0
> from=<root>
> Jan 23 20:01:00 shlomo1 postfix/cleanup[10110]: 56BED8ECD:
> message-id=<20060123180100.56BED8ECD_at_shlomo1.solomon>
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: 56BED8ECD:
> from=<root_at_shlomo1.solomon>, size=469, nrcpt=1 (queue active)
> ----->Jan 23 20:01:00 shlomo1 postfix/pickup[25600]: 5BB018ECC: uid=0
> from=<root>
> Jan 23 20:01:00 shlomo1 postfix/cleanup[10110]: 5BB018ECC:
> message-id=<20060123180100.5BB018ECC_at_shlomo1.solomon>
> Jan 23 20:01:00 shlomo1 postfix/local[10112]: 56BED8ECD:
> to=<solomon_at_shlomo1.solomon>, orig_to=<solomon>, relay=local, delay=0,
> status=sent (delivered to mailbox)
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: 56BED8ECD: removed
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: 5BB018ECC:
> from=<root_at_shlomo1.solomon>, size=473, nrcpt=1 (queue active)
> Jan 23 20:01:00 shlomo1 postfix/local[10112]: 5BB018ECC:
> to=<solomon_at_shlomo1.solomon>, orig_to=<solomon>, relay=local, delay=0,
> status=sent (delivered to mailbox)
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: 5BB018ECC: removed
> ----->Jan 23 20:01:00 shlomo1 postfix/pickup[25600]: A58C78ECD: uid=0
> from=<root>
> Jan 23 20:01:00 shlomo1 postfix/cleanup[10113]: A58C78ECD:
> message-id=<20060123180100.A58C78ECD_at_shlomo1.solomon>
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: A58C78ECD:
> from=<root_at_shlomo1.solomon>, size=481, nrcpt=1 (queue active)
> ----->Jan 23 20:01:00 shlomo1 postfix/pickup[25600]: AA5C28ECC: uid=0
> from=<root>
> Jan 23 20:01:00 shlomo1 postfix/cleanup[10110]: AA5C28ECC:
> message-id=<20060123180100.AA5C28ECC_at_shlomo1.solomon>
> Jan 23 20:01:00 shlomo1 postfix/local[10112]: A58C78ECD:
> to=<solomon_at_shlomo1.solomon>, orig_to=<solomon>, relay=local, delay=0,
> status=sent (delivered to mailbox)
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: A58C78ECD: removed
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: AA5C28ECC:
> from=<root_at_shlomo1.solomon>, size=469, nrcpt=1 (queue active)
> ----->Jan 23 20:01:00 shlomo1 postfix/pickup[25600]: B64A18ECB: uid=0
> from=<root>
> Jan 23 20:01:00 shlomo1 postfix/cleanup[10113]: B64A18ECB:
> message-id=<20060123180100.B64A18ECB_at_shlomo1.solomon>
> Jan 23 20:01:00 shlomo1 postfix/local[10112]: AA5C28ECC:
> to=<solomon_at_shlomo1.solomon>, orig_to=<solomon>, relay=local, delay=0,
> status=sent (delivered to mailbox)
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: AA5C28ECC: removed
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: B64A18ECB:
> from=<root_at_shlomo1.solomon>, size=463, nrcpt=1 (queue active)
> Jan 23 20:01:00 shlomo1 postfix/local[10112]: B64A18ECB:
> to=<solomon_at_shlomo1.solomon>, orig_to=<solomon>, relay=local, delay=0,
> status=sent (delivered to mailbox)
> Jan 23 20:01:00 shlomo1 postfix/qmgr[8546]: B64A18ECB: removed
> ----->Jan 23 20:51:00 shlomo1 postfix/pickup[12999]: A2EEB8EBF: uid=0
> from=<root>
> Jan 23 20:51:00 shlomo1 postfix/cleanup[21618]: A2EEB8EBF:
> message-id=<20060123185100.A2EEB8EBF_at_shlomo1.solomon>
> Jan 23 20:51:00 shlomo1 postfix/qmgr[8546]: A2EEB8EBF:
> from=<root_at_shlomo1.solomon>, size=1079, nrcpt=1 (queue active)
> Jan 23 20:51:00 shlomo1 postfix/local[21620]: A2EEB8EBF:
> to=<solomon_at_shlomo1.solomon>, orig_to=<solomon>, relay=local, delay=0,
> status=sent (delivered to mailbox)
> Jan 23 20:51:00 shlomo1 postfix/qmgr[8546]: A2EEB8EBF: removed
>
>
>
> So what's happening to delay cron from sending that mail?
>
> BTW, I have a similar (but not identical) problem in cron.daily but am not
> giving details now since maybe a soution to the hourly problem will help
> solve the daily problem.
>
>
> --
> Shlomo Solomon
> http://the-solomons.net
> Sent by KMail (KDE 3.4.2) on LINUX Mandriva 2006
>
>
> =================================================================
> To unsubscribe, send mail to linux-il-request_at_linux.org.il with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail linux-il-request_at_linux.org.il
>
>

================================To unsubscribe, send mail to linux-il-request_at_linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request_at_linux.org.il



This archive was generated by hypermail 2.1.7 : Tue 24 Jan 2006 - 10:27:02 IST