View Full Version : Cron Jobs Overflowing
goosed
January 11th, 2009, 05:49
Hi all, I have a question about cron jobs. When I execute certain scripts, I notice they begin to fill up in my running processes. For example, I see over 100 "cron: running job (cron)" when I do a ps ax.
My question is why does this happen? And is there a command or something that I can add in to my current scripts to stop it from repeating?
Thank you.
trev
January 11th, 2009, 08:14
It happens because your scripts are running those other processes, all of which are being run by cron. I wouldn't worry about it.
SirDice
January 11th, 2009, 10:43
Add something like this:
if [ -e /var/run/mysript ]
echo 'Still running'
exit
endif
touch /var/run/myscript
{do your stuff}
rm /var/run/myscript
goosed
January 11th, 2009, 19:36
Thanks for the replies. SirDice, what exactly does that script do?
trev
January 12th, 2009, 10:34
I don't believe SirDice's script has any utility in your situation. It is designed to stop a single script from running again if it is already running.
Unless I misunderstood your first post, your situation is simply that your script is executing subshells (eg each individual command in a pipeline is run as a separate process in a subshell). Subshells show up as additional copies of your script in the process table because your script is their parent.
SirDice
January 12th, 2009, 11:56
As I understood it the cronjob gets fired off even when there's still a previous one running.
To prevent this from happening you will need to add something to the script that indicates the script is running. The bit of code I posted does this. It exits if the 'marker' exists.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.