Schedule php script on windows

1

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

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

It's working fine, the problem is that every time the task runs, it opens a new Chrome, so it gets dozens of Chromes open.

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

    
asked by anonymous 19.07.2017 / 23:07

3 answers

0

Hello, I managed to solve it, I did the bat with the command to execute the script but it was giving error. first I needed to add the PHP variable to the environment variables so I added the php.exe path in Path

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

Now it's working right.

Thank you for your help!

    
20.07.2017 / 21:00
1

You do not need to run through the browser.

Run PHP from the command line.

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

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

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

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

    
20.07.2017 / 01:54
0

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

bat content will look like this

php -f arquivo.php
    
19.07.2017 / 23:32