Location: PHPKode > scripts > Periodic site maintenance > periodic-site-maintenance/job_sample.php
 @desc periodic job calling script, using as_nightjobs.php using example
 @author Alexander Selifonov <as-hide@address.com> <hide@address.com>
 @link http://www.selifan.ru
 last modified : 26.01.2009

# connect to MySQL db !
# Your MySQL host, login, password and database name.

$job = new CNightJobs('my demo site');

$job->SetAdminEmail('hide@address.com'); # where to send report

# $job->AddTableToShrink('user_activity_log,'event_date');
# here is some table that need to be cleaned from obsolete records
# multiple callable (if there's more than one table to shrink)

$tblist = array('depts','employees','salary','sales');
# all tables to manage (optimize and place to backup)

if(date('w')==0) {
  #  make backups once a week (on sunday) even if this script called daily
  $job->SetBackupParameters('backups/', 28,null, 'mybckp-');
# data backups saved in backups folder, 5 days file rotation, bckp file named "mybckp-YYYY-MM-DD"

$job->SetUserFunction('MyJobs'); # MyJobs is a function with Your specific operations

# Root Document folder is '.', 
# site 'size growth history' saved into table 'sitestats',
# my tariff plan space limit is 100 MB

$job->Exec(); # Let's Go !

Return current item: Periodic site maintenance