* * * * * d:/test/test.php 

I wrote this command in crontab, instead of executing this script, it just opens the file, please tell me how to run this script

  • one
    php "d:\test\test.php" ? your file is not executed by itself, its interpreter must process - teran
  • @teran, do not tell me how you can run it - Vadim
  • I did not write the line to start corrected in the comments above? or is it not working? If it does not work, then enter the path to php.exe in the PATH environment variable. That is, you need to run the interpreter php, and point it to the input name of your script. - teran
  • @teran, thank you, everything worked - Vadim
  • issued a response. - teran

1 answer 1

In fact, cron does what you tell it to do — executes the specified file. The default action for php files in Windows is to open it in the editor, which is what happens.
You need to execute the file using the php interpreter. To do this, you need to run php.exe in the crown and specify the path to the file being processed. As a result, your launch team should look like this:

 * * * * * php "d:\test\test.php" 

This command will work if the path to the directory where it is located, php.exe registered in the PATH environment variable. Otherwise, you will need to either add this directory to the PATH , or specify the full path to the php.exe file.

* Formally, if you return to the original team, then it can also work. However, for this you will need to configure the default action for php files and choose the interpreter php.exe itself as the default program, not the text editor.