suhkha's avatar

Cron job of my custom command in Laravel 4.2

Hi, I know there is Laravel 5.* but now and for many reasons I've using Laravel 4.2

So I have a custom command, and in the fire() method, the action I do is import a file and seed the information in my database, so my class is some like this...

class SeedDataFile extends Command {
    protected $name = 'import:file';

    public function fire(){
        $command = 'mongoimport --db things --collection users --type csv --file file.csv --headerline';
        $result = exec($command, $output, $return);
    }
}

So I want the file is seeding data, i.e. every 12 hours (considering the file every 12 hours is changing with new data), but as an user I don't wanna type the command in my terminal:

php artisan import:file

...every 12 hours (I just wanna upload the new file to my project).

So the cron job is where do all the work, but I don't wanna to do this:

crontab -e

...and edit the file...

I wanna setup the schedule of my command in one class o somewhere in the code, and automatically the custom command is running everyday until a determined date.

Is this possible? Or I have to configure the crontab file?

Thank you so much! And sorry for my english!

:)

0 likes
0 replies

Please or to participate in this conversation.