Set up cron jobs to run php file (Nginx server)


A cron job or cron task is a Linux command used for scheduling tasks to be executed sometime in the future. This is normally used to schedule a job that is executed.

We will often set up cron jobs to run specific scripts in our server that will do something.

 

To se up a cron job in your NGINX server:

Start open your terminal, log in into your server and open the cron config file by running the following command:

sudo crontab -e

This will open a file where you can add multiple cron jobs.

For example, you can add the following line to run a php file in your server at an specific time, in this case every day at 19:00

0 19 * * * /usr/bin/php -f /var/www/domain.com/cron.php >> /var/log/cron.log 2>&1

The first 5 characters determine when the cron job will be run:

* * * * *

minute – hour – day (month)month – day (week)

 

You can find more information on how to set up an specific time on this website: crontab.guru

LIFETIME.SOLUTIONS - LIFETIME.SOLUTIONS -