Halfagain IM Forums
May 17, 2012, 08:00 *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Due to increasing spam we are forced to make this forum "Read Only". If you have an issue, most likely was discussed here. Use the Search function and try to find related discussions. If you can't find any helpful information, just email support at halfagain dot com"
 
   Home   Help Login Register  
Pages: [1] 2
  Print  
Author Topic: Overlapping cronjobs  (Read 10430 times)
0 Members and 2 Guests are viewing this topic.
Deliguy
Newbie
*

Karma: 10
Offline Offline

Posts: 48


« on: July 19, 2006, 16:52 »

I ran into a problem with my cronjobs overlapping. I set each cronjob to every five minutes in order to fit them all in but they started to fall behind and causing a massive build up on the server.

So i made a quick script that pulls all the cronjob commands from a text file and runs them one by one. The next script doesn't start till the one before it finishes. This seems to be working out for me and is causing a lot less pain on the server. It also makes adding cronjobs a lot easier and I can add as many domains as I'd like without ever overloading the server. Since its always running no more than one job.

If this sounds like something all you noncoders out there might be interested in getting your hands on let me know and I'll post it up.


Update

Here it is guys and gals.
Download Link: http://www.bluehatseo.com/tbs/tbscron.zip



Description: This in a sense is a concatinated cronjob script for TBS. you run one cronjob and it will first check to see if the script has finished from the last time it ran(checks the first line of crons.txt for a 0). If it is still in the process of running then it quietly exits. If it is complete then it begins, and starts one by one executing all the cronjobs you listed in crons.txt. This ensures that the script never overlaps itself, so you can technically have as many tbs domains as you would like, it would just automatically spread out the cronjobs to run less often. It also makes it a ton easier to add and edit your probably huge growing list of cronjobs. You can set the cronjob script to run as often as you'd like(i run once per hour).




#Instructions
1-open cron.cgi and crons.txt in notepad. edit the "path to crons.txt line" with your full server path to the crons.txt. Then make sure the first line in crons.txt is 0 and then list all your cronjobs on seperate lines below it. Add as many as you'd like.

2-upload cron.cgi and crons.txt to the cgi-bin on your webserver. chmod permissions on cron.cgi to 755 and crons.txt to 777.

3-put in a cronjob that runs the cron.cgi
example:
perl /var/www/mydomain.com/www/cgi-bin/cron.cgi

set the cronjob to as often as you would like(I use every hour, i wouldn't recommend any less than that).
« Last Edit: July 21, 2006, 19:03 by Deliguy » Logged

This was a post from your friendly neighborhood Blue Hatter
BlueHatSEO.com
Everyone gets one Smiley
rcd
Newbie
*

Karma: 10
Offline Offline

Posts: 3


« Reply #1 on: July 19, 2006, 18:22 »

Id be interested if you can post the code.  TIA!
Logged
webgrafix
Newbie
*

Karma: 10
Offline Offline

Posts: 36


« Reply #2 on: July 20, 2006, 17:15 »

PLEASE share this!!!
Logged

[COLOR="Blue"][size="3"]Webgrafix[/size][/COLOR]
FREE SERVICES FOR TBS MEMBERS:[/b]
[SIZE="2"]DeliFresh Social Bookmarking Site[/SIZE][/URL]... Tag and Ping!
[size="1"]BlogWarz! A free blogging service available to TBS users!
WebGrafix Proxy Service! Surf Anonymously!
SMS Gateway Send quick easy test to any cell phone!
Check PageRank Check Google PageRank of any page![/SIZE]
shortcuts
Jr. Member
**

Karma: 10
Offline Offline

Posts: 100


« Reply #3 on: July 21, 2006, 09:51 »

yes we will all need this as we build deeper!

thanks for your ablities;)

shortcuts
Logged

Deliguy
Newbie
*

Karma: 10
Offline Offline

Posts: 48


« Reply #4 on: July 21, 2006, 19:04 »

posted. check update above
Logged

This was a post from your friendly neighborhood Blue Hatter
BlueHatSEO.com
Everyone gets one Smiley
smaxor
Jr. Member
**

Karma: 10
Offline Offline

Posts: 121


« Reply #5 on: July 22, 2006, 14:19 »

Nice work Deliguy!!! Always nice to see a fellow coder on here.
Logged

neiq
Newbie
*

Karma: 10
Offline Offline

Posts: 9


« Reply #6 on: July 23, 2006, 19:38 »

Hello,
I'm trying to get this working when i run the cgi i get the message
Running Crons... not working not working Done!
but when i check it didn't run what command are we suppose to put in the crons.txt ?
/usr/bin/php /home/username/public_html/batch/index.php
or
http://www.domain.com/batch/index.php
?

Quote from: Deliguy
I ran into a problem with my cronjobs overlapping. I set each cronjob to every five minutes in order to fit them all in but they started to fall behind and causing a massive build up on the server.

So i made a quick script that pulls all the cronjob commands from a text file and runs them one by one. The next script doesn't start till the one before it finishes. This seems to be working out for me and is causing a lot less pain on the server. It also makes adding cronjobs a lot easier and I can add as many domains as I'd like without ever overloading the server. Since its always running no more than one job.

If this sounds like something all you noncoders out there might be interested in getting your hands on let me know and I'll post it up.


Update

Here it is guys and gals.
Download Link: http://www.bluehatseo.com/tbs/tbscron.zip



Description: This in a sense is a concatinated cronjob script for TBS. you run one cronjob and it will first check to see if the script has finished from the last time it ran(checks the first line of crons.txt for a 0). If it is still in the process of running then it quietly exits. If it is complete then it begins, and starts one by one executing all the cronjobs you listed in crons.txt. This ensures that the script never overlaps itself, so you can technically have as many tbs domains as you would like, it would just automatically spread out the cronjobs to run less often. It also makes it a ton easier to add and edit your probably huge growing list of cronjobs. You can set the cronjob script to run as often as you'd like(i run once per hour).




#Instructions
1-open cron.cgi and crons.txt in notepad. edit the "path to crons.txt line" with your full server path to the crons.txt. Then make sure the first line in crons.txt is 0 and then list all your cronjobs on seperate lines below it. Add as many as you'd like.

2-upload cron.cgi and crons.txt to the cgi-bin on your webserver. chmod permissions on cron.cgi to 755 and crons.txt to 777.

3-put in a cronjob that runs the cron.cgi
example:
perl /var/www/mydomain.com/www/cgi-bin/cron.cgi

set the cronjob to as often as you would like(I use every hour, i wouldn't recommend any less than that).
Logged
Deliguy
Newbie
*

Karma: 10
Offline Offline

Posts: 48


« Reply #7 on: July 24, 2006, 03:13 »

Neiq,
check your crons.txt. It should look like this. Also make sure it is in ascii mode and chmod permissions to 777

0
/usr/bin/php /home/username/public_html/batch/index.php

the fact that you got two non working print outs tells me you didn't include the first line with the 0
Logged

This was a post from your friendly neighborhood Blue Hatter
BlueHatSEO.com
Everyone gets one Smiley
silvi
Newbie
*

Karma: 10
Offline Offline

Posts: 36


« Reply #8 on: August 18, 2006, 14:12 »

so does this addon system run once 1 day or...?
with this usage;

0
/usr/bin/php /home/username/public_html/batch/index.php

how could we set the time to work?
for example for once a day?
Logged
Deliguy
Newbie
*

Karma: 10
Offline Offline

Posts: 48


« Reply #9 on: August 18, 2006, 20:00 »

silvia,
the cronjobs can run as often as you'd like. Consider this addon like a cronjob consolidator. You run one cronjob and it runs all the rest sequentially. So if you want them all to run once a day then run the one cronjob once a day.

put this as your cronjob.
perl /var/www/mydomain.com/www/cgi-bin/cron.cgi
Logged

This was a post from your friendly neighborhood Blue Hatter
BlueHatSEO.com
Everyone gets one Smiley
Omar
Here to help.
Administrator
Hero Member
*****

Karma: 10001
Offline Offline

Posts: 2687


« Reply #10 on: August 18, 2006, 20:18 »

I think this one deserve a sticky.

Keep up with the good work.
Logged
kiladen
Newbie
*

Karma: 10
Offline Offline

Posts: 4


« Reply #11 on: August 19, 2006, 04:01 »

I tried and tried but I couldn't get this to work.   All I got was

Content-type: text/html

Running Crons...
not working
not working

I made sure crons.txt had 0 as the first line, and I put the crons below that.  Has anyone else gotten it to work?  What can I be doing wrong?  I made sure all my paths were right and quadruple checked them.
Logged
neiq
Newbie
*

Karma: 10
Offline Offline

Posts: 9


« Reply #12 on: August 19, 2006, 10:53 »

same here :confused:
Quote from: kiladen
I tried and tried but I couldn't get this to work.   All I got was

Content-type: text/html

Running Crons...
not working
not working

I made sure crons.txt had 0 as the first line, and I put the crons below that.  Has anyone else gotten it to work?  What can I be doing wrong?  I made sure all my paths were right and quadruple checked them.
Logged
Deliguy
Newbie
*

Karma: 10
Offline Offline

Posts: 48


« Reply #13 on: August 21, 2006, 23:51 »

try setting the 0 to a 1
i did accidently release for awhile a version that had the check statement wrong. That may be hte problem.
Logged

This was a post from your friendly neighborhood Blue Hatter
BlueHatSEO.com
Everyone gets one Smiley
silvi
Newbie
*

Karma: 10
Offline Offline

Posts: 36


« Reply #14 on: September 02, 2006, 10:23 »

when we use 0
it gives "not work" error
when we use 1,
it gives no error but it doesn't work
I run cron.cgi and it says "Running Crons... working"
but nothing changed about my domain
no change "adding blogs" or "adding posts"
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!