Thursday, September 24, 2009

Missing jobs will be executed.

As I cannot control the server downtime caused by my hosting provider, from now on, all missing jobs after a downtime will be executed later.

There are 3 solutions:

- Execute all missing jobs when my server is up.
This is a big bang :D and of course I don't use it :)

- Execute all missing jobs along with new jobs.
E.g, my server is down at 22:01, and it's up again at 23:01, so at 23:05, it will execute all cron jobs that should be executed at 22:05 (missing jobs) and 23:05 (new jobs).

But this may be a bit terrible if your heavy script (e.g backing up) run at the same time: if you set cron job every 30 minutes, at 23:30, it will run twice a minute :(

- Execute all cron jobs 3 times faster than normal.
With the example above, at 23:05, it will execute all cron jobs that should execute at 22:05, 22:10, 22:15.
At 23:05, it will execute all cron jobs that should execute at 22:20, 22:25, 22:30.
....

This will affect all normal cron jobs, but it the best way that I can do :)

After the downtime length / 2, every thing will go normally.

Sunday, September 6, 2009

Basic HTTP Authentication

A bug on Basic HTTP Authentication has been fixed. 

If users try to create a cron job with URL containing username:password@, the URL becomes scheme://1domain.name/path.....

Thanks Fred for informing me :)

Saturday, September 5, 2009

Set cron jobs with PHP scripts

Here are some tips to make your PHP script work perfectly:

Official tips

Add

<?php
set_time_limit(0);
ignore_user_abort(1);
?>

at beginning of your php file(s). This will let your script run until it finishes all jobs and doesn't care about users' stop button :)

Thanks Francesco for this tip :)

Personal tip

As most shared hosting disable functions set_time_limit and/or ignore_user_abort, you'd better don't output anything, or your output should be less than 4KB. Remember not to force your script to output (i.e using flush).

I tried it with shared hosting and my current server (LAMP), and my script which requires 150 seconds to complete works perfectly when set cron job at SetCronJob.

Wednesday, September 2, 2009

Connection time and response time

I've split Execution time into Connection time and Response time.

From now all, when viewing cron jobs' logs, you will see these two values.

For example, here's part of my logs for URL http://www.setcronjob.com/

Last execution time : Wed, 02 Sep 2009 11:45:08 UTC
Connection time : 0.0144
Response time : 0.000835
Output:

HTTP/1.1 200 OK
Date: Wed, 02 Sep 2009 11:45:08 GMT
Server: Apache
X-Powered-By: PHP/5.1.6
Content-Length: 6195
Connection: close
Content-Type: text/html; charset=UTF-8
Content-Language: en

.........

At SetCronJob, the max connection time is 3 seconds, and max response time is 2 seconds.