Skip to main content
wpcrux.com

Back to all posts

How to Run A Cron Job In CakePHP?

Published on
6 min read

Table of Contents

Show more
How to Run A Cron Job In CakePHP? image

Running a cron job in CakePHP involves the following steps:

  1. Locate the CakePHP root directory: Navigate to the root directory of your CakePHP application. This is where you will perform the following steps.
  2. Create a new shell: In the src/Shell/ directory, create a new file with a .php extension. This file will serve as your shell for the cron job. For example, you can create a file named MyCronShell.php.
  3. Define the shell class: Open the shell file and create a new class that extends the Shell class provided by CakePHP. This class will contain the logic for your cron job. For example: