To use a cron job in OctoberCMS, you will need to follow these steps:
- Open the Terminal/Command Prompt and navigate to the root directory of your OctoberCMS installation.
- Run the following command to generate the cron file:
php artisan october:env
This command will create a .env.october file in the root directory.
- Open the .env.october file and add your cron job configuration. For example, if you want to run a cron job every minute, you can add the following line:
* * * * * php /path/to/your/artisan/artisan schedule:run >> /dev/null 2>&1
Replace /path/to/your/artisan/artisan with the actual path to your artisan file.
- Save the file and rename it to .env. Drop the .october extension.
- Set up the cron job on your server. The exact steps will depend on your server configuration, but usually, you can do this by using the crontab -e command to edit your cron table and then adding the command you added to the .env file.
- Save the changes to your cron table.
Now, the cron job will run automatically at the specified interval and execute the
schedule:run command in OctoberCMS, which will trigger any registered scheduled tasks defined in your application.