Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
vixie cron creating 20 instances of script process
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
lightweave
n00b
n00b


Joined: 18 Feb 2005
Posts: 26

PostPosted: Wed Mar 30, 2005 7:33 am    Post subject: vixie cron creating 20 instances of script process Reply with quote

I have a normnal bash script installed in the crontab which is run at 4AM. On my old machine this was always very slow and I thought that it was because this was a 233MHz machine, so I didn't investigate it. Now on the new server I noticed again that the machine is very unresponsive which was strange because this is now a 1.2GHz machine and it shouldn't be that slow.

When I looked at the processes I noticed that this backup script was running about 20 times but I don't know why. I can change the script to make sure that it runs only one instance per run, which would make sense in that case, but I still would like to know what I'm doing wrong. I have made the script executable and simply entered it in /etc/crontab. Do I need to run it with a bash process? Normally this is not needed because the system automatically does this. The only thing that I could think of, would be that cron starts the script and somehow the process detaches so fast that cron thinks there is something wrong and starts it again, until it hits a limit.

Is this assumption correct or is there something else to consider? What I noticed is that that in the process list the 20 instances all have their own cron process. I thought that there should rather be one cron process which runs the script, so why does it for so often? Any hints would be appreciated.
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Wed Mar 30, 2005 1:29 pm    Post subject: Reply with quote

Why don't you start by posting /etc/crontab ?
Post the script too while you're at it.

Perhaps it really is started 20 times in succession.
If any cron job doesn't terminate before the next one is started that is its own problem - the cron job itself has to make sure that it completes within the time available.
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
Maedhros
Bodhisattva
Bodhisattva


Joined: 14 Apr 2004
Posts: 5511
Location: Durham, UK

PostPosted: Wed Mar 30, 2005 1:42 pm    Post subject: Reply with quote

Moved from Installing Gentoo.
_________________
No-one's more important than the earthworm.
Back to top
View user's profile Send private message
lightweave
n00b
n00b


Joined: 18 Feb 2005
Posts: 26

PostPosted: Wed Mar 30, 2005 1:44 pm    Post subject: Reply with quote

adaptr wrote:
Why don't you start by posting /etc/crontab ?
Post the script too while you're at it.


Because I'm currently not at home. And before I went to work, the actions on the machine took so long that I couldn't wait for it, so I need to wait until I get back home. :)

I thought mabye I'm missing something obvious and get a quick answer. Somtimes problems are obvious for an expert while others are baffled by them.

Quote:
Perhaps it really is started 20 times in succession.


It definitely it, but it shouldn't. :) 20 is just a guess. I counted it from the screen so it can be 25 or 22 but it's in the range of 20.

Quote:
If any cron job doesn't terminate before the next one is started that is its own problem - the cron job itself has to make sure that it completes within the time available.


That shouldn't be the problem. The process finishes well before the evening. When I get back home in the evening everything is normal. That's why I didn't notice this problem much earlier. I think the script should not run longer then 1 or 2 minutes (if that long), but let it run 5 minutes, it still shouldn't be started as often.

I post the crontab entry and the script when I get back home.
Back to top
View user's profile Send private message
lightweave
n00b
n00b


Joined: 18 Feb 2005
Posts: 26

PostPosted: Wed Mar 30, 2005 5:32 pm    Post subject: Reply with quote

Crontab ------------------------------------------------------
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
0 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
1 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
15 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
30 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons
* 4 * * * root /usr/local/bin/sys_bak
End Crontab ------------------------------------------------------



sys_bak ------------------------------------------------------
#!/bin/bash

# Create a daily backup of the CVS

BDATE=`date '+%u'`
/bin/rm /backup/cvs_backup-$BDATE.tgz 2>/dev/null
/bin/tar -czpsf /backup/cvs_backup-$BDATE.tgz /cvsroot

/bin/rm /backup/mysql_backup-$BDATE.tgz 2>/dev/null
/bin/tar -czpsf /backup/mysql_backup-$BDATE.tgz /mnt/disk1/mysql_data
End sys_bak ------------------------------------------------------



ps ------------------------------------------------------

6380 ? Ss 0:01 /usr/sbin/cron
4677 ? S 0:00 \_ /usr/sbin/cron
4679 ? Ss 0:00 | \_ /bin/bash /usr/local/bin/sys_bak
4684 ? D 0:05 | | \_ /bin/tar -czpsf /backup/cvs_backup-3.tgz /cvsroot
4688 ? S 1:25 | | \_ gzip
4689 ? S 0:00 | \_ /usr/sbin/sendmail -FCronDaemon -odi -oem -oi -t
4713 ? S 0:00 \_ /usr/sbin/cron
4718 ? Ss 0:00 | \_ /bin/bash /usr/local/bin/sys_bak
4735 ? D 0:03 | | \_ /bin/tar -czpsf /backup/cvs_backup-3.tgz /cvsroot
4738 ? S 1:03 | | \_ gzip
4739 ? S 0:00 | \_ /usr/sbin/sendmail -FCronDaemon -odi -oem -oi -t
4768 ? S 0:00 \_ /usr/sbin/cron
4785 ? Ss 0:00 | \_ /bin/bash /usr/local/bin/sys_bak
4817 ? D 0:03 | | \_ /bin/tar -czpsf /backup/cvs_backup-3.tgz /cvsroot
4818 ? S 0:47 | | \_ gzip
4819 ? S 0:00 | \_ /usr/sbin/sendmail -FCronDaemon -odi -oem -oi -t
4822 ? S 0:00 \_ /usr/sbin/cron
4839 ? Ss 0:00 | \_ /bin/bash /usr/local/bin/sys_bak
4877 ? D 0:07 | | \_ /bin/tar -czpsf /backup/cvs_backup-3.tgz /cvsroot
4878 ? S 2:14 | | \_ gzip
4879 ? S 0:00 | \_ /usr/sbin/sendmail -FCronDaemon -odi -oem -oi -t
4828 ? S 0:00 \_ /usr/sbin/cron
4838 ? Ss 0:00 | \_ /bin/bash /usr/local/bin/sys_bak
4883 ? D 0:13 | | \_ /bin/tar -czpsf /backup/cvs_backup-3.tgz /cvsroot
4884 ? S 3:25 | | \_ gzip
4885 ? S 0:00 | \_ /usr/sbin/sendmail -FCronDaemon -odi -oem -oi -t
4833 ? S 0:00 \_ /usr/sbin/cron
4853 ? Ss 0:00 | \_ /bin/bash /usr/local/bin/sys_bak
4881 ? D 0:06 | | \_ /bin/tar -czpsf /backup/cvs_backup-3.tgz /cvsroot
4894 ? S 2:01 | | \_ gzip
4895 ? S 0:00 | \_ /usr/sbin/sendmail -FCronDaemon -odi -oem -oi -t
End ps ------------------------------------------------------

The script sys_bak should only be executed at 4Am which it is. But as you can see from the ps output it is executed many times at once, which it shouldn't. The list is much longer, I just posted this to show a sample.
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Wed Mar 30, 2005 5:44 pm    Post subject: Reply with quote

No it shouldn't - you specified it to run at every minute between 4:00 and 4:59...
man crontab ;-)
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
lightweave
n00b
n00b


Joined: 18 Feb 2005
Posts: 26

PostPosted: Wed Mar 30, 2005 6:32 pm    Post subject: Reply with quote

adaptr wrote:
No it shouldn't - you specified it to run at every minute between 4:00 and 4:59...
man crontab ;-)


AAAAHHHHH!!! Thanks! Yes. Now that you mention it ... :oops:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum