Salve a tutti, mi servirebbe un cronjobs che mi eliminasse i record che hanno come valore la data odierna!..ho proceduto cosi ma non mi funge:
console.php
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// preloading 'log' component
'preload'=>array('log'),
'import'=>array(
'application.components.*',
'application.models.*',
),
// application components
'components'=>array(
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=database',
'emulatePrepare' => true,
'username' => 'admin',
'password' => 'admin',
'charset' => 'utf8',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'logFile'=>'cron.log',
'levels'=>'error, warning',
),
array(
'class'=>'CFileLogRoute',
'logFile'=>'cron_trace.log',
'levels'=>'trace',
),
),
),
),
);
OfferteCronCommand
<?php
class OfferteCronCommand extends CConsoleCommand
{
public function getHelp()
{
echo "Deleted unconfirmed registration entries";
}
public function run($args)
{
Offerte::model()->deleteAllByAttributes(array(
'data_fin'=>date('Y,m,d'),
));
}
}
poi da linux(centos…,vps su aruba)
root: cd /etc
root: vi crontab -l
Sme command to be executed
.
.
name command to be executed
HELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
07 10 * * * /usr/bin/php /var/www/vhosts/nomedominio/hhtdocs/CartellaApplicazione/protected/console.php OfferteCronCommand
ma non elimina niente…,mi manca qualcosa??