{"id":46458,"date":"2024-06-10T12:24:07","date_gmt":"2024-06-10T07:24:07","guid":{"rendered":"https:\/\/devrims.com\/?p=46458"},"modified":"2025-06-05T17:09:47","modified_gmt":"2025-06-05T12:09:47","slug":"laravel-cron-job-task-scheduling","status":"publish","type":"post","link":"https:\/\/devrims.com\/blog\/laravel-cron-job-task-scheduling\/","title":{"rendered":"How to Use Laravel Cron Jobs for Tasks Automation?"},"content":{"rendered":"\r\n\r\n\r\n\r\n\r\n\r\n\n<p>Laravel is one of the most commonly used PHP frameworks. There are situations for developers when they have to schedule tasks rather than manually edit or view code. For this reason, a cron job in Laravel is used. This article will help you <a href=\"https:\/\/devrims.com\/blog\/learn-laravel-free-paid-resources-websites\/\" target=\"_blank\" rel=\"noreferrer noopener\">learn about Laravel<\/a> cron jobs, scheduling, and the most commonly used cron job commands.<\/p>\n\n\n\n<h2 id='what-is-cron-job-in-laravel'  id=\"boomdevs_1\" class=\"wp-block-heading\">What is Cron Job in Laravel?<\/h2>\n\n\n\n<p>Cron&#8217;s job is a Unix command to execute job scheduling at a specific interval. For instance, you may send daily\/weekly reports by task scheduling. It will execute a script to auto-send the reports.<\/p>\n\n\n\n<p>Cron jobs are used for <a href=\"https:\/\/www.tableau.com\/learn\/articles\/what-is-data-cleaning\" rel=\"nofollow noopener\" target=\"_blank\">data cleaning<\/a>, email sending, executing time-consuming tasks, etc. Suppose you want to auto-delete records older than a month from the database every day at midnight. Cron Job will do that for you.<\/p>\n\n\n\n<p>A configuration file known as Crontable or Crontab is used for scheduling. A crontab may comprise various cronjobs. A cronjob contains two parts: a shell command and a cron expression. Every cron job has a particular task.<\/p>\n\n\n\n<p>The format of the Cron scheduler is as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">* * * * * command\/to \/run<\/pre>\n\n\n\n<p>* Will be replaced by minute, hour, day, month, day of the week.<\/p>\n\n\n\n<p>Provided that:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Minute (0-59)<\/li>\n\n\n\n<li>Hour (0-23)<\/li>\n\n\n\n<li>Day of month (1-31)<\/li>\n\n\n\n<li>Month (1-12)<\/li>\n\n\n\n<li>Day of the week (0-6, starting on Sunday-0)<\/li>\n<\/ul>\n\n\n\n<p>The Cron job will be executed at regular intervals or defined times according to the details specified in the cron.<\/p>\n\n\n\n<h3 id='laravel-cron-job-samples'  id=\"boomdevs_2\" class=\"wp-block-heading\">Laravel Cron Job Samples<\/h3>\n\n\n\n<p>Every hour on the 10th minute of the hour.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">10 * * * * command-to \u2013 run<\/pre>\n\n\n\n<p>If you want to run every hour on the 10th minute of the hour on Tuesdays, then:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">10 * * * 2 command-to- run<\/pre>\n\n\n\n<p>If you want to run a cron job at regular intervals of time, for example, every 20 minutes, then<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">*\/20 * * * * command- to \u2013 run<\/pre>\n\n\n        <div class=\"cta-banner laravel mb-3\" style=\"background-image: url(https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/02\/Laravel-CTA-BG.png);\">\r\n            <div class=\"container\">\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t<div class=\"col-md-7\">\r\n\t\t\t\t\t\t<h2>Struggling to <span class='bg-color'>Scale<\/span> Your Laravel Application?<\/h2>\r\n\t\t\t\t\t\t<p>Effortlessly scale your Laravel application with our hassle-free cloud servers and one-click vertical scaling. <br>\r\n<b>Unlock Effortless Scaling Today!<\/b><\/p>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t<div class=\"cta-btn-wrapper\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/user.devrims.com\/signup?utm_source=Blogs&#038;utm_medium=CTAs&#038;utm_campaign=Conversions\" target=\"_blank\" class=\"btn btn-primary\">Avail 3-days Free Trial Now!<\/a>\r\n\t\t\t\t\t\t\t<span class=\"cta-btn-bottom-title\">No Credit Card Required<\/span>\r\n\t\t\t\t\t\t\t<style>\r\n\t\t\t\t\t\t\t\t:has(.DevOps) .cta-btn-bottom-title{\r\n\t\t\t\t\t\t\t\t\tdisplay: none;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t<\/style>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<div class=\"col-md-5\">\r\n\t\t\t\t\t\t<div class=\"cloud-partner-wrapper\">\r\n\t\t\t\t\t\t\t<!-- <h3>Cloud Partners<\/h3> -->\r\n\t\t\t\t\t\t\t<div class=\"cloud-partners-images\">\r\n\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/02\/Laravel-image-new-3.svg\" class=\"Laravel1\" alt=\"\">\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\t\t\t<\/div>\r\n        <\/div>\r\n        \n\n\n\n<h2 id='schedules'  id=\"boomdevs_3\" class=\"wp-block-heading\">Schedules<\/h2>\n\n\n\n<p>You can define scheduled tasks in the schedule method of your application&#8217;s kernel class, which is located at App\/Console\/Kernel.<\/p>\n\n\n\n<p>Some examples are mentioned below for scheduling tasks with different commands.<\/p>\n\n\n\n<h2 id='task-scheduling-in-laravel'  id=\"boomdevs_4\" class=\"wp-block-heading\">Task Scheduling in Laravel<\/h2>\n\n\n\n<p>The command scheduler feature in Laravel enables you to define the command schedule within Laravel. For scheduling, you should use SSH to add cron entries. You will need a single Cron entry on a server to run the Laravel task scheduler every minute.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"938\" height=\"278\" src=\"https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/03\/laravel-cron-job-1.webp\" alt=\"Task Scheduling in Laravel\" class=\"wp-image-68713\" srcset=\"https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/03\/laravel-cron-job-1.webp 938w, https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/03\/laravel-cron-job-1-300x89.webp 300w, https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/03\/laravel-cron-job-1-768x228.webp 768w, https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/03\/laravel-cron-job-1-24x7.webp 24w, https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/03\/laravel-cron-job-1-36x11.webp 36w, https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/03\/laravel-cron-job-1-48x14.webp 48w\" sizes=\"auto, (max-width: 938px) 100vw, 938px\" \/><\/figure>\n\n\n\n<p>Laravel\u2019s task schedule is defined in the app\/Console\/Kernel.php file, and its<a style=\"font-style: inherit; background-color: #ffffff;\" href=\"https:\/\/laravel.com\/docs\/9.x\/scheduling#:~:text=Laravel&#039;s%20command%20scheduler%20offers%20a,is%20needed%20on%20your%20server.\" rel=\"nofollow noopener\" target=\"_blank\">&nbsp;task scheduler<\/a> is defined in the schedule method.<\/p>\n\n\n\n<p>This method helps define many tasks. To call the Laravel command scheduler, you must add the Cron entry to your server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">* * * * * php \/path\/to\/artisan schedule:run &gt;&gt; \/dev\/null 2&gt;&amp;1<\/pre>\n\n\n\n<p>The above cronjob will start the task scheduler to run tasks inside the schedule method.<\/p>\n\n\n\n<h2 id='command-scheduling-in-laravel'  id=\"boomdevs_5\" class=\"wp-block-heading\">Command Scheduling in Laravel<\/h2>\n\n\n\n<p>We may use the Laravel task scheduler to schedule the commands. Tasks were defined inside the schedule method of the Kernel class. The command method enables artisan commands. In contrast, the schedule method enables the scheduling of all commands. You may set different frequencies that may apply to the commands that are needed. A few of the examples are mentioned below:<\/p>\n\n\n\n<p>If a task is supposed to be executed once a day, then the daily() method is valid.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Protected function schedule(Schedule $schedule)\n{\n$schedule-&gt;command(\u2018sms:gudmorning\u2019)-&gt;daily();\n}\n--&nbsp;&nbsp;&nbsp; If we want to run tasks every hour every day.\n$schedule-&gt;command(\u2018Task\u2019)\n-&gt;hourly();<\/pre>\n\n\n\n<p><strong>For example, you want to run a task daily at 11.30, then\u00a0 <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$schedule-&gt;command(\u2018Task\u2019)\n-&gt;dailyAt(\u201811.30\u2019);<\/pre>\n\n\n\n<p><strong>If you have to run a job every week, then:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$schedule-&gt;command(\u2018Task\u2019)\n-&gt;weekly( );<strong>&nbsp;<\/strong><\/pre>\n\n\n\n<p><strong>If you have to run a job every month, then:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$schedule-&gt;command(\u2018Task\u2019)\n-&gt;monthly( );<\/pre>\n\n\n\n<p>We may also provide schedule constraints. If necessary, we may combine the above methods to perform some actions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$schedule-&gt;command(\u2018Task\u2019)\n-&gt;weekly( );\n-&gt;mondays();\n-&gt;at(10.30);<\/pre>\n\n\n\n<h3 id='scheduling-artisan-commands'  id=\"boomdevs_6\" class=\"wp-block-heading\">Scheduling Artisan Commands<\/h3>\n\n\n\n<p>Laravel Cron jobs may be implemented in various ways, and we&#8217;ve already seen how closures can be used to schedule these tasks.<\/p>\n\n\n\n<p>Using artisan commands to manage tasks in an application is another technique. Laravel provides an interactive command-line interface for us to use to construct commands.<\/p>\n\n\n\n<p>Let&#8217;s make a command that will be used to schedule tasks.<\/p>\n\n\n\n<p>By running the following command, we will construct a command to schedule emails:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">PHP artisan make: command emails<\/pre>\n\n\n\n<p>It will create the emails.php file in the app\/Console\/Commands directory.<\/p>\n\n\n\n<h3 id='what-is-the-php-artisan-command'  id=\"boomdevs_7\" class=\"wp-block-heading\">What is the PHP artisan Command?<\/h3>\n\n\n\n<p>You might not be familiar with Laravel artisan commands if you haven&#8217;t worked with them before. Developers use PHP Artisan to accomplish a variety of critical actions, such as producing migrations, publishing package assets, and other related tasks.<\/p>\n\n\n\n<p>In Artisan, you may not only use built-in Laravel commands, but you can also create your own unique Laravel commands.<\/p>\n\n\n\n<p>You may use many pre-built Laravel artisan commands, but many developers prefer to construct their own commands based on project requirements. Type the following command for a list of pre-built PHP Laravel artisan commands.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">PHP artisan list<\/pre>\n\n\n\n<p>A list of built-in PHP Laravel artisan commands will be provided. These instructions aid developers in performing their tasks more efficiently, ultimately saving their time. You can construct auth, controller, model, mail, migration, and many other functions using these Laravel artisan commands.<\/p>\n\n\n\n<h3 id='run-the-schedule-command-for-a-test'  id=\"boomdevs_8\" class=\"wp-block-heading\">Run the Schedule Command for a test<\/h3>\n\n\n\n<p>To check if schedule commands have been constructed successfully, run this command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">php artisan schedule: run<\/pre>\n\n\n\n<p>After that, go to the logs folder inside the storage directory, open the Laravel.php cron job file, and check it.<\/p>\n\n\n\n<p><strong>Note: <\/strong>You can use this command for a Laravel scheduler without a cron job.<\/p>\n\n\n\n<h2 id='scheduling-closure-calls'  id=\"boomdevs_9\" class=\"wp-block-heading\">Scheduling Closure calls<\/h2>\n\n\n\n<p>You may also schedule a closure for calling every day at midnight, and within the closure, a database query will be executed for clearing the table.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">protected function schedule(Schedule $schedule)\n{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $schedule-&gt;call(function () {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DB::table('recent_users')-&gt;delete();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; })-&gt;daily();\n}<\/pre>\n\n\n\n<h2 id='scheduling-exec-shell-commands'  id=\"boomdevs_10\" class=\"wp-block-heading\">Scheduling Exec\/Shell Commands<\/h2>\n\n\n\n<p>If you want to issue a command to the operating system, then you should use the exec command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$schedule-&gt;exec('node \/home\/forge\/script.js')-&gt;daily();<\/pre>\n\n\n\n<h2 id='schedule-queued-jobs'  id=\"boomdevs_11\" class=\"wp-block-heading\">Schedule Queued Jobs<\/h2>\n\n\n\n<p>A queued job can be scheduled using the job method. This function makes it simple to schedule queued jobs without having to use the call method to declare closures:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$schedule-&gt;job(new JobName)-&gt;everyFiveMinutes();<\/pre>\n\n\n\n<h2 id='schedule-options-available-in-laravel'  id=\"boomdevs_12\" class=\"wp-block-heading\">Schedule options available in Laravel<\/h2>\n\n\n\n<p>We may use various schedules in our tasks. A few of them are as follows:<\/p>\n\n\n\n<p>The different types of schedules we can assign to our tasks are,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">-&gt;cron(\u2018* * * * * *\u2019);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      \u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task on a custom Cron schedule\n-&gt;everyMinute();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every minute\n-&gt;everyFiveMinutes();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every five minutes\n-&gt;everyTenMinutes();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every ten minutes\n-&gt;everyThirtyMinutes();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every thirty minutes\n-&gt;hourly();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every hour\n-&gt;daily();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every day at midnight\n-&gt;dailyAt(\u201913:00\u2032);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every day at 13:00\n-&gt;twiceDaily(1, 13);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task daily at 1:00 &amp; 13:00\n-&gt;weekly();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every week\n-&gt;monthly();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every month\n-&gt;monthlyOn(4, \u201915:00\u2032);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run the task every month on the 4th at 15:00\n-&gt;quarterly();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run&nbsp; the task every quarter\n-&gt;yearly();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use to run&nbsp; the task every year\n-&gt;timezone(\u2018America\/New_York\u2019);&nbsp; \u2014    &nbsp;&nbsp;&nbsp; Use to run Set the timezone<\/pre>\n\n\n\n<p>Moreover, additional schedule constraints are listed as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">-&gt;weekdays();      \u2014&nbsp;&nbsp; Use to Limit the task to weekdays\n-&gt;sundays();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;  Use to run Limit the task to Sunday\n-&gt;mondays();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp; Use to run Limit the task to Monday\n-&gt;tuesdays();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;&nbsp; Use to run Limit the task to Tuesday\n-&gt;wednesdays();    \u2014&nbsp;&nbsp; Use to run Limit the task to Wednesday\n-&gt;thursdays();     \u2014&nbsp;&nbsp; Use to run Limit the task to Thursday\n-&gt;fridays();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2014&nbsp;  Use to run&nbsp; Limit the task to Friday\n-&gt;saturdays();     \u2014&nbsp;&nbsp; Use to run Limit the task to Saturday\n-&gt;when(Closure);   \u2014&nbsp;  Use to run Limit the task based on a truth test<\/pre>\n\n\n\n<p><strong>Note:<\/strong><\/p>\n\n\n\n<p>Laravel Task Scheduler has many advantages; one of the most important advantages is that we can focus on creating commands and writing logic. It is manageable by other co-workers because it is now tracked by version control. Laravel will take care of the rest.<\/p>\n\n\n\n<p>If you want to deploy your application on the server in just one click, get <a href=\"https:\/\/devrims.com\/laravel-hosting\/\">Laravel hosting<\/a>.<\/p>\n\n\n\n<h2 id='conclusion'  id=\"boomdevs_13\" class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this article, I discussed practical ways to schedule tasks using different Laravel commands. I also demonstrated the most commonly used schedules and ways to assign tasks to the scheduler according to time. In the comments section, share your experience with a Laravel cron job.<\/p>\n\n\n        <div class=\"cta-banner laravel mb-3\" style=\"background-image: url(https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/02\/Laravel-CTA-BG.png);\">\r\n            <div class=\"container\">\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t<div class=\"col-md-7\">\r\n\t\t\t\t\t\t<h2>Host Unlimited Apps and Domains with <span class='bg-color'>One-Click Deployment<\/span><\/h2>\r\n\t\t\t\t\t\t<p>Easily deploy unlimited apps and domains with just one click, supported by our reliable infrastructure and expert support.\r\n<b>Experience Unlimited Freedom!<\/b><\/p>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t<div class=\"cta-btn-wrapper\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/user.devrims.com\/signup?utm_source=Blogs&#038;utm_medium=CTAs&#038;utm_campaign=Conversions\" target=\"_blank\" class=\"btn btn-primary\">Avail 3-days Free Trial Now!<\/a>\r\n\t\t\t\t\t\t\t<span class=\"cta-btn-bottom-title\">No Credit Card Required<\/span>\r\n\t\t\t\t\t\t\t<style>\r\n\t\t\t\t\t\t\t\t:has(.DevOps) .cta-btn-bottom-title{\r\n\t\t\t\t\t\t\t\t\tdisplay: none;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t<\/style>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<div class=\"col-md-5\">\r\n\t\t\t\t\t\t<div class=\"cloud-partner-wrapper\">\r\n\t\t\t\t\t\t\t<!-- <h3>Cloud Partners<\/h3> -->\r\n\t\t\t\t\t\t\t<div class=\"cloud-partners-images\">\r\n\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/devrims.com\/blog\/wp-content\/uploads\/2025\/02\/Laravel-2-Image-05-2.svg\" class=\"Laravel4\" alt=\"\">\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\t\t\t<\/div>\r\n        <\/div>\r\n        \n\n\n\n<h2 id='frequently-asked-questions'  id=\"boomdevs_14\" class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n<div ><style>#sp-ea-67878 .spcollapsing { height: 0; overflow: hidden; transition-property: height;transition-duration: 300ms;}#sp-ea-67878.sp-easy-accordion>.sp-ea-single {margin-bottom: 10px; border: 1px solid #e2e2e2; }#sp-ea-67878.sp-easy-accordion>.sp-ea-single>.ea-header a {color: #444;}#sp-ea-67878.sp-easy-accordion>.sp-ea-single>.sp-collapse>.ea-body {background: #fff; color: #444;}#sp-ea-67878.sp-easy-accordion>.sp-ea-single {background: #eee;}#sp-ea-67878.sp-easy-accordion>.sp-ea-single>.ea-header a .ea-expand-icon { float: left; color: #444;font-size: 16px;}<\/style><div id=\"sp_easy_accordion-1740036948\"><div id=\"sp-ea-67878\" class=\"sp-ea-one sp-easy-accordion\" data-ea-active=\"ea-click\" data-ea-mode=\"vertical\" data-preloader=\"\" data-scroll-active-item=\"\" data-offset-to-scroll=\"0\"><div class=\"ea-card ea-expand sp-ea-single\"><h3 id='what-is-the-purpose-of-cron-jobs-in-laravel'  id=\"boomdevs_15\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-678780\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse678780\" aria-controls=\"collapse678780\" href=\"#\" aria-expanded=\"true\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-minus\"><\/i> What is the purpose of cron jobs in Laravel?<\/a><\/h3><div class=\"sp-collapse spcollapse collapsed show\" id=\"collapse678780\" data-parent=\"#sp-ea-67878\" role=\"region\" aria-labelledby=\"ea-header-678780\"> <div class=\"ea-body\"><p>Cron jobs in Laravel are used to schedule tasks at regular intervals (e.g., daily, hourly). They automate repetitive tasks such as sending emails, cleaning the database, or generating reports.<\/p><\/div><\/div><\/div><div class=\"ea-card sp-ea-single\"><h3 id='can-i-schedule-multiple-cron-jobs-in-laravel'  id=\"boomdevs_16\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-678781\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse678781\" aria-controls=\"collapse678781\" href=\"#\" aria-expanded=\"false\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-plus\"><\/i> Can I schedule multiple cron jobs in Laravel?<\/a><\/h3><div class=\"sp-collapse spcollapse \" id=\"collapse678781\" data-parent=\"#sp-ea-67878\" role=\"region\" aria-labelledby=\"ea-header-678781\"> <div class=\"ea-body\"><p>Yes, you can schedule multiple cron jobs. Define them in the app\/Console\/Kernel.php file using the schedule() method. For example:<\/p><pre class=\"wp-block-code\"><code>protected function schedule(Schedule $schedule){\u00a0\u00a0\u00a0\u00a0$schedule-&gt;command('emails:send')-&gt;daily();\u00a0\u00a0\u00a0\u00a0$schedule-&gt;command('backup:run')-&gt;weekly();}<\/code><\/pre><p>This will schedule the tasks to run daily and weekly, respectively.<\/p><\/div><\/div><\/div><div class=\"ea-card sp-ea-single\"><h3 id='what-is-the-difference-between-queue-and-cron-in-laravel'  id=\"boomdevs_17\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-678782\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse678782\" aria-controls=\"collapse678782\" href=\"#\" aria-expanded=\"false\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-plus\"><\/i> What is the difference between queue and cron in laravel?<\/a><\/h3><div class=\"sp-collapse spcollapse \" id=\"collapse678782\" data-parent=\"#sp-ea-67878\" role=\"region\" aria-labelledby=\"ea-header-678782\"> <div class=\"ea-body\"><p>A queue runs tasks in the background, meaning they are handled separately from the main process, like sending emails or processing images. A cron job, on the other hand, schedules tasks to run at specific times or intervals, such as performing backups or generating reports.<\/p><\/div><\/div><\/div><div class=\"ea-card sp-ea-single\"><h3 id='how-to-run-a-php-file-using-cronjob'  id=\"boomdevs_18\" class=\"ea-header\"><a class=\"collapsed\" id=\"ea-header-678783\" role=\"button\" data-sptoggle=\"spcollapse\" data-sptarget=\"#collapse678783\" aria-controls=\"collapse678783\" href=\"#\" aria-expanded=\"false\" tabindex=\"0\"><i aria-hidden=\"true\" role=\"presentation\" class=\"ea-expand-icon eap-icon-ea-expand-plus\"><\/i> How to run a PHP file using CronJob?<\/a><\/h3><div class=\"sp-collapse spcollapse \" id=\"collapse678783\" data-parent=\"#sp-ea-67878\" role=\"region\" aria-labelledby=\"ea-header-678783\"> <div class=\"ea-body\"><p>To\u00a0<a href=\"https:\/\/devrims.com\/blog\/how-to-run-a-php-file-using-xampp\/\" target=\"_blank\" rel=\"noreferrer noopener\">run a PHP file<\/a>\u00a0using a cron job, add the following line to your server\u2019s crontab:<\/p><pre class=\"wp-block-code\"><code>0 0 * * * \/usr\/bin\/php \/path\/to\/your\/script\/example.php<\/code><\/pre><p>Alternatively, in Laravel, you can use the exec() method in the scheduler to run the PHP file:<\/p><pre class=\"wp-block-code\"><code>$schedule-&gt;exec('php \/path\/to\/script\/example.php')-&gt;daily();<\/code><\/pre><\/div><\/div><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>You can add a task scheduling feature with Laravel Cron Jobs. Use different commands and create classes to add this functionality.<\/p>\n","protected":false},"author":5,"featured_media":68377,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[14,15],"tags":[20,50],"ad-banner":[86],"blog-popup":[81],"cta-banner":[],"class_list":["post-46458","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-laravel","tag-featured","tag-laravel-development","ad-banner-laravel","blog-popup-app-laravel"],"acf":[],"_links":{"self":[{"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/posts\/46458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/comments?post=46458"}],"version-history":[{"count":30,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/posts\/46458\/revisions"}],"predecessor-version":[{"id":69649,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/posts\/46458\/revisions\/69649"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/media\/68377"}],"wp:attachment":[{"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/media?parent=46458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/categories?post=46458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/tags?post=46458"},{"taxonomy":"ad-banner","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/ad-banner?post=46458"},{"taxonomy":"blog-popup","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/blog-popup?post=46458"},{"taxonomy":"cta-banner","embeddable":true,"href":"https:\/\/devrims.com\/blog\/wp-json\/wp\/v2\/cta-banner?post=46458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}