Reputation: 5053
I have a Laravel 5 app, it works fine. Then, I have a plain PHP script that I need to execute every X time (could be minutes, hours or even every X days) so, I want to execute it automatically using Laravel, how can I do it and which is the proper way to achieve this? I don't want to manually be running the script. And also, can I do this in the same Laravel app or should I create a new one? Currently I have to execute the script using the CLI.
Upvotes: 0
Views: 101
Reputation: 17658
You can use Cron jobs to execute commands or scripts (groups of commands) automatically at a specified time/date.
e.g.
01 * * * * root echo "This command is run at one min past every hour"
17 8 * * * root echo "This command is run daily at 8:17 am"
17 20 * * * root echo "This command is run daily at 8:17 pm"
00 4 * * 0 root echo "This command is run at 4 am every Sunday"
* 4 * * Sun root echo "So is this"
42 4 1 * * root echo "This command is run 4:42 am every 1st of the month"
01 * 19 07 * root echo "This command is run hourly on the 19th of July"
Upvotes: 1
Reputation: 455
You can use Task Scheduling, it makes scheduling anything you need to quite simple.
https://laravel.com/docs/5.3/scheduling
^ Have a look through the link you should be able to find everything you need
Upvotes: 1