You are not logged in.

#1 2010-04-22 13:39:58

jeffmikels
Member
Registered: 2007-04-19
Posts: 37

crond spawns multiple copies of my script

Using:
   Linux [FQDN] 2.6.33-ARCH #1 SMP PREEMPT Mon Apr 5 05:57:38 UTC 2010 i686 AMD Sempron(tm) Processor 3000+ AuthenticAMD GNU/Linux
   dcron 4.4-2


I have the following script saved as 'backup' in my /etc/cron.daily directory:

#!/bin/bash

BACKUP=/var/scripts/backup2

nice $BACKUP --clean /etc /boot /share /srv/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt

My backup2 script is a python script that does the following: (1) walks the directories passed to it on the command line. (2) backs up updated files to backup drive (3) maintains an archive of old versions.

The script has been working fine for me for two years and it is still working fine, but after my latest update to dcron, run-cron spawns nine copies of the script simultaneously. Every morning when I check the server, I have these nine processes running:

[jeff@adam log]$ ps aux |grep backup
root      4380  0.0  0.0   4544   412 ?        S    03:52   0:00 /bin/bash /etc/cron.daily/backup
root      4381  2.1  0.2   7132  2400 ?        DN   03:52   6:37 python /var/scripts/backup2 --clean /etc /boot /share /sr                               v/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt
root      4444  0.0  0.0   4544   412 ?        S    04:02   0:00 /bin/bash /etc/cron.daily/backup
root      4445  2.1  0.2   7128  2596 ?        DN   04:02   6:25 python /var/scripts/backup2 --clean /etc /boot /share /sr                               v/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt
root      4500  0.0  0.0   4544   424 ?        S    04:12   0:00 /bin/bash /etc/cron.daily/backup
root      4501  2.1  0.2   7124  2588 ?        DN   04:12   6:16 python /var/scripts/backup2 --clean /etc /boot /share /sr                               v/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt
root      4555  0.0  0.0   4544   436 ?        S    04:22   0:00 /bin/bash /etc/cron.daily/backup
root      4556  2.2  0.2   7128  2380 ?        RN   04:22   6:11 python /var/scripts/backup2 --clean /etc /boot /share /sr                               v/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt
root      4645  0.0  0.0   4544   444 ?        S    04:32   0:00 /bin/bash /etc/cron.daily/backup
root      4646  2.2  0.2   7128  2392 ?        DN   04:32   6:02 python /var/scripts/backup2 --clean /etc /boot /share /sr                               v/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt
root      4743  0.0  0.0   4544   436 ?        S    04:41   0:00 /bin/bash /etc/cron.daily/backup
root      4744  2.2  0.2   7124  2364 ?        DN   04:41   5:59 python /var/scripts/backup2 --clean /etc /boot /share /sr                               v/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt
root      4790  0.0  0.0   4544   452 ?        S    04:51   0:00 /bin/bash /etc/cron.daily/backup
root      4791  2.4  0.2   7128  2284 ?        DN   04:51   6:06 python /var/scripts/backup2 --clean /etc /boot /share /sr                               v/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt
root      4849  0.0  0.0   4544   460 ?        S    05:01   0:00 /bin/bash /etc/cron.daily/backup
root      4850  2.4  0.2   7132  2376 ?        DN   05:01   5:59 python /var/scripts/backup2 --clean /etc /boot /share /sr                               v/www /home /var/scripts /var/cache/pacman/pkg /var/lib/mysql /opt
jeff      7043  0.0  0.0   3832   840 pts/0    S+   09:02   0:00 grep backup

Can anyone tell me why crond is spawning multiple copies of the scripts in its daily directory? All the other scripts in the directory run quickly. If one script fails on an error, will run-cron reprocess the entire queue?


...using Arch as a home server since 2006.

Offline

#2 2010-04-22 15:22:59

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: crond spawns multiple copies of my script

It's a bug in cron to run @daily, @hourly, etc jobs on wrong schedules. Jim is working on it.

If you want to work around it, either switch to using a manually-defined time instead of @daily, or put some locking in /etc/cron.daily/backup.

Offline

#3 2010-04-22 22:32:42

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,362

Re: crond spawns multiple copies of my script

Ah, that would explain why pkgfile ran itself multiple times the other day... thanks ataraxia


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#4 2010-04-23 13:36:41

jeffmikels
Member
Registered: 2007-04-19
Posts: 37

Re: crond spawns multiple copies of my script

Was this bug reported in the news feed? I didn't see it.


...using Arch as a home server since 2006.

Offline

#5 2010-04-23 13:38:50

jeffmikels
Member
Registered: 2007-04-19
Posts: 37

Re: crond spawns multiple copies of my script

Here's my modified crontab:

# root crontab
# DO NOT EDIT THIS FILE MANUALLY! USE crontab -e INSTEAD

# man 1 crontab for acceptable formats:
#    <minute> <hour> <day> <month> <dow> <tags and command>
#    <@freq> <tags and command>

# SYSTEM DAILY/WEEKLY/... FOLDERS
#@hourly         ID=sys-hourly   /usr/sbin/run-cron /etc/cron.hourly
20      *       *       *       *       ID=sys-hourly   /usr/sbin/run-cron /etc/cron.hourly

#@daily          ID=sys-daily    /usr/sbin/run-cron /etc/cron.daily
30      01      *       *       *       ID=sys-daily    /usr/sbin/run-cron /etc/cron.daily

#@weekly         ID=sys-weekly   /usr/sbin/run-cron /etc/cron.weekly
40      02      *       *       00      ID=sys-weekly   /usr/sbin/run-cron /etc/cron.weekly

#@monthly        ID=sys-monthly  /usr/sbin/run-cron /etc/cron.monthly
50      03      01      *       *       ID=sys-monthly  /usr/sbin/run-cron /etc/cron.monthly

...using Arch as a home server since 2006.

Offline

Board footer

Powered by FluxBB