How cron.php works for watchdog? I want to truncate the table 'watchdog' once a day. 

So I heave:


to set the maximum rows number from the 'Logging and Alerts' (of Site Configuration) to 1000
create a crontab on my system to run the root/cron.php once a day


But I can't understand how the process goes. The crontab calls the cron.php . What is the process next?

I see the file cron.php includes the bootstrap.inc. Why is that?

Where is the actual code with the mysql queries (truncate) inside?

I need to understand the process to make some changes to a site.

I have googled it enough and have not find any information.
cron.php initiates a call to function drupal_cron_run() (in common.inc) which will finally make all calls to all cron tasks.

/**
 * Executes a cron run when called
 * @return
 * Returns TRUE if ran successfully
 */
function drupal_cron_run() {
.
.
// Iterate through the modules calling their cron handlers (if any):
module_invoke_all('cron'); // This will call all cron functions defined in modules(enabled)
.
.
}


dblog_cron() will get invoked by module_invoke_all('cron') This is responsible for clearing old entries in your watchdog table. If this function does not suit your requirements you can use Ultimate Cron to disable it alone. This is a good admin tool to manage your cron jobs. Then you can write your own cron task in another module and enable it.

function dblog_cron() {
  // Cleanup the watchdog table
  $max = db_result(db_query('SELECT MAX(wid) FROM {watchdog}'));
  db_query('DELETE FROM {watchdog} WHERE wid &lt;= %d', $max - variable_get('dblog_row_limit', 1000));
}


Note : This is wrt Drupal 6. in D7 module invoke is slightly different