cron job run multiple number of times?

  • Follow


Hello.

I noticed (?) that one the cron jobs on my system seems to get executed
a multiple number of times:

--($:~)-- ps -ef | grep -v grep | grep start_backup
    root 28818 28817   0 03:38:34 ?           0:00 /bin/sh /.backup/start_backup
    root 20155   374   0   Sep 15 ?           0:00 sh -c /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
    root 28817     1   0 03:38:34 ?           0:00 /bin/sh /.backup/start_backup
    root 23711   374   0   Sep 16 ?           0:00 sh -c /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
    root  2201  2199   0   Sep 14 ?           0:00 /bin/sh /.backup/start_backup
    root 28175   374   0   Sep 14 ?           0:00 sh -c /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
    root 26764     1   0   Sep 16 ?           0:00 /bin/sh /.backup/start_backup
    root 26765 26764   0   Sep 16 ?           0:00 /bin/sh /.backup/start_backup
    root 23619 23617   0   Sep 15 ?           0:00 /bin/sh /.backup/start_backup
    root 25787   374   0 02:55:01 ?           0:00 sh -c /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
    root 23617     1   0   Sep 15 ?           0:00 /bin/sh /.backup/start_backup
    root  2199     1   0   Sep 14 ?           0:00 /bin/sh /.backup/start_backup

This job should only be run once by the following cron job:

--($:~)-- sudo crontab -l|grep start_
55 2 * * *      /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log

I wonder why the script seems to get executed more than once. The script
doesn't call itself recursively, see <http://askwar.pastebin.ca/700390>.
I'm refering to the lines 1, 3 and 3rd to last of the ps output I pasted
above. What's going on there at 03:38:34?

Thanks a lot,

Alexander Skwar
0
Reply alexander930 (342) 9/17/2007 6:59:35 AM

The script seems to hang, as you have processes from Sep 14,15,16 and
17 (today) still alive.

What's in /tmp/backup.log? Does the script actually ever get to the
end?

If you add a "echo `date` >> /tmp/starttimes.backup.log" to the
beginning of the script, you will see when and if the script is
actually started several times.

I'm guessing that the script is done at 03:38 and leaves orphan
processes as it does not exit cleanly.

Regards, Arvid


0
Reply arvid 9/17/2007 11:21:30 AM


On Sep 17, 7:59 am, Alexander Skwar <alexan...@skwar.name> wrote:
> Hello.
>
> I noticed (?) that one the cron jobs on my system seems to get executed
> a multiple number of times:
>
> --($:~)-- ps -ef | grep -v grep | grep start_backup
>     root 28818 28817   0 03:38:34 ?           0:00 /bin/sh /.backup/start_backup
>     root 20155   374   0   Sep 15 ?           0:00 sh -c /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
>     root 28817     1   0 03:38:34 ?           0:00 /bin/sh /.backup/start_backup
>     root 23711   374   0   Sep 16 ?           0:00 sh -c /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
>     root  2201  2199   0   Sep 14 ?           0:00 /bin/sh /.backup/start_backup
>     root 28175   374   0   Sep 14 ?           0:00 sh -c /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
>     root 26764     1   0   Sep 16 ?           0:00 /bin/sh /.backup/start_backup
>     root 26765 26764   0   Sep 16 ?           0:00 /bin/sh /.backup/start_backup
>     root 23619 23617   0   Sep 15 ?           0:00 /bin/sh /.backup/start_backup
>     root 25787   374   0 02:55:01 ?           0:00 sh -c /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
>     root 23617     1   0   Sep 15 ?           0:00 /bin/sh /.backup/start_backup
>     root  2199     1   0   Sep 14 ?           0:00 /bin/sh /.backup/start_backup
>
> This job should only be run once by the following cron job:
>
> --($:~)-- sudo crontab -l|grep start_
> 55 2 * * *      /bin/sh /.backup/start_backup 2>&1 | /usr/bin/tee /tmp/backup.log
>
> I wonder why the script seems to get executed more than once. The script
> doesn't call itself recursively, see <http://askwar.pastebin.ca/700390>.
> I'm refering to the lines 1, 3 and 3rd to last of the ps output I pasted
> above. What's going on there at 03:38:34?

I suspect fairly strongly that the script either calls itself or
perhaps forks a background job. Using ptree on some of the processes
would probably be informative (for instance 23619 is a child of 23617,
and I'm guessing 374 is cron).

--tim

0
Reply Tim 9/17/2007 2:09:24 PM

Alexander Skwar wrote:

>     root 28818 28817   0 03:38:34 ?           0:00 /bin/sh /.backup/start_backup

>     root 28817     1   0 03:38:34 ?           0:00 /bin/sh /.backup/start_backup


> I wonder why the script seems to get executed more than once. The script
> doesn't call itself recursively, see <http://askwar.pastebin.ca/700390>.
> I'm refering to the lines 1, 3 and 3rd to last of the ps output I pasted
> above. What's going on there at 03:38:34?

It is not executing more than once, it is forking.  I guess the script is 
hanging in some of the loops or ( ) forks.
0
Reply Oscar 9/17/2007 2:29:08 PM

3 Replies
609 Views

(page loaded in 3.483 seconds)

Similiar Articles:













7/22/2012 3:43:20 PM


Reply: