Schedule php script in windows

Asked

Viewed 1,607 times

1

Hello, I have a php script that needs to run automatically every 15 minutes in windows (my system is hosted locally).

Well, I saw that it has to be by the scheduler of windows tasks so I configured as follows: I added a basic task and selected to start Chrome and put the script path in the arguments (localhost/script.php).

It’s working fine, the problem is that every time the task is executed, it opens a new Chrome, then gets dozens of Chromes open.

I wonder if there is any other way to do this scheduling or some command or option to execute the task in the window already open or simply reload the page, because as the script will be running 24 hours a day, one hour someone will have to close these windows.

  • 1

    I don’t know how this task scheduler works, but by the logic, what I thought is: Open for the first time and schedule a task to press F5.

3 answers

1

No need to run through the browser.

Run PHP by command line.

In the task scheduler specify the same command you would use for cmd (prompt)

c:\local\do\compilador\php.exe -f c:\local\do\script.php

Be aware that some features behave differently under CLI (command line interface), but usually will not have problems.

*Prefer to specify the full path of the compiler and script to run. Avoid relative paths.

0


Hello, I managed to fix, I bat with the command to run the script but was giving error. first needed to add the PHP variable to the environment variables so I added the php.exe path to the path

so, I had problems with the "include" files of my script, I had to change the code to include(DIR . '/config.php');

Now it’s working right.

I appreciate your help!

0

You can create a file .bat run your php page, and your bat you put in the task scheduler.

the contents of the bat will be as follows:

php -f arquivo.php
  • Hello, I tried both in . bat and putting the direct command on the scheduler, it runs but does nothing.. know if there’s any log that I can see what’s going on?

  • I don’t know if it’s pq to using wamp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.