Log in to the server with a user with permissions to create schedules.
For this you can use SSH (console) or use features of site management tools such as Plesk, CPnel, etc.
Via console (SSH), after logging in, run
crontab -e
This will open the logged in user's schedules file.
For your case, you should create a schedule that runs every minute. Add something like this:
1 * * * * php /caminho/completo/do/script.php
To start editing, press the "I" key. It depends on the linux distribution and the text editor.
Save the file change
(pressione) ESC
(digite) :wq
(pressione) ENTER
The letters wq mean " w rite" and " q uit".
To make sure it is actually scheduled, run
crontab -l
A list of schedules will be displayed.
However, this still does not guarantee much. If there are any errors in the file path or the file script fails, you will not know if there is no log, monitoring, etc.
To see if the path is correct, run on the console
php /caminho/completo/do/script.php
And see what happens. To test, put a echo time();
at the end or put a mail()
to send an email, file_put_contents()
to create a file, anyway. Make up what is convenient for testing.
Using a manager such as Plesk, CPanel, etc., will have a page to create schedules in a friendlier way without using a console.
Usually just type the same command
1 * * * * php /caminho/completo/do/script.php
CPanel is similar to this. The images are illustrative.