Forum Moderators: phranque

Message Too Old, No Replies

Cron job issue

running long duration php script as cron job

         

pushpendragold

10:08 pm on Feb 21, 2010 (gmt 0)

10+ Year Member



Hi all,

I am required to run some calculation script on my server which takes more then 4 hours to execute. When I set cron job using wget it creates multiple instances of same process, which overloads server and site stops working. I don't know what to do

please help.
Thanks

physics

4:53 pm on Feb 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How often do you need the job to run?

pushpendragold

7:33 pm on Feb 26, 2010 (gmt 0)

10+ Year Member



requires daily.

physics

5:56 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If it takes 4 hours to run and you want it to run daily then you shouldn't be having a problem.
Maybe your cron syntax is wrong - can you post it here?

pushpendragold

8:42 pm on Mar 1, 2010 (gmt 0)

10+ Year Member



here is crontab code
5 0 * * * /usr/bin/wget
http://www.mydomain.com/do-calculation.php

g1smd

8:57 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Does the script have to run over HTTP?

I use something like:

30 3 * * * /usr/bin/[b]php[/b] [b]/var/www/[/b]example.com/cron/script.php [b]>>[/b] /home/username/logs/cronlog.log


to run scripts internally (and log some output).

physics

7:49 pm on Mar 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does the server get overloaded right away or only after a few days of this running?

pushpendragold

11:39 pm on Mar 3, 2010 (gmt 0)

10+ Year Member



the server get overloaded after 15 to 20 mins. To check multiple instances I placed mail sending code in cronjob.php and I received nearly 20 mails which shows that at least 20 instances of same cron job was running.
So currently I am manually doing this task every day :(.

physics

12:04 am on Mar 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it possible that the script is calling itself? This is really strange. It's either a bug in your cron daemon (very unlikely) or a bug in your script.
Have you checked /var/log/cron?

pushpendragold

6:44 pm on Mar 4, 2010 (gmt 0)

10+ Year Member



Hi physics thnax for understanding my problem.
Script is fine as opening cron job URL manually does not overload server.
Is there any timeout thing in crontab or may be in wget which occurred and cause recalling of URL?