CakePHP: Running Shell Script with Cronjob

By | May 27, 2014

Create a Shell Script

Create a ScheduleShell.php in cakephp/app/Console/Command.

<?php
class ScheduleShell extends Shell {
    function main() {
    	$this->out('Hello World');
    }
}
?>

Add a cronjob

sudo crontab -e

I have a cronjob running every 5 minute for ScheduleShell.php

# cronjob run every 5 minute
*/5  *    *    *    * cd /var/www/html/cakephp/app && Console/cake schedule

Leave a Reply

Your email address will not be published. Required fields are marked *

3 × 3 =