You can use this blog in order to do what you want. You could then use cron or someother program to trigger the action.
In summary:
First of all, you need to create a symfony command that executes the functionality that you wish. For that, create a folder named "Command" in our Bundle at the same level that we have "Controller or Resources" and put a name in our class. The name has to end with "Command" or it won't work. Let's call it "MyCommand".
<?php
namespace Devvness\DevvnessBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MyCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('devvness:my_command')
->setDescription('Descripción de lo que hace el comando')
->addArgument('my_argument', InputArgument::OPTIONAL, 'Explicamos el significado del argumento');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getContainer()->get('doctrine')->getManager();
// Hacemos lo que sea
$output->writeln('Hola mundo');
$em->flush();
}
}
Then you can call it by executing on cmd or console:
php app/console devness:mycommand
or
php app/console devness:mycommand --my_argument=valor
Then you need to scheduled the task with cron for Unix or something like that by editing the cron file
* * * * * php /root/absolute/for/symfony/project/app/console devness:mycommand --myargument=valor