How to let Linux execute a php file per 5 minutes thread safety?

90 Views Asked by At

I have a scree.php file in the path:

xxx/.../Home/scree.php

I want to execute it per 5 minutes, and make sure it is thread-safety. How to do that?

I am under XShell.

2

There are 2 best solutions below

0
On

You can edit the crontab in XShell:

crontab -e

Then in the file, you should add the code:

*/5 * * * * root usr/bin/php xxx/.../Home/scree.php

Then esc :wq out of the file.

If it shows:

crontab: installing new crontab

means success.

0
On

It can be done using crontab.

  1. Type "crontab -e" in your terminal.
  2. Paste in the following code:

    */5 * * * * php /Home/scree.php

  3. Exit out of your editor.

Learn more about crontab here.