PHP script scheduling in Windows

Asked

Viewed 333 times

1

I have a test environment VM with Windows Server + Xampp.

I need to fire a file (script.php) scheduled every 5 minutes.

What is the simplest and most agile way ?

Update 1

By the Windows "Task Scheduler", the shortest range is "daily":

Agendador de Tarefas

  • Scheduler of windows tasks

  • I put to run the file php ?

  • can run php type.php file or direct file url

  • It only has "daily". With break in minutes no !

  • 1

    https://stackoverflow.com/questions/4249542/run-a-task-every-x-minutes-with-windows-task-scheduler

  • In uma vez it does not open the range value?

  • @rray no, it opens a date and time only.

  • @Otto that’s it ! Want to post the answer ? If not I do the prints and post... I will test if it will work the execution...

  • It didn’t work. I put to run the file in . php, wouldn’t it be the same thing as clicking it to open ? That way he doesn’t have a standard program...

  • I made an edit in the reply by putting how to run the scripts

Show 5 more comments

2 answers

2


The task must be set in two steps.

First you must create a simple task starting at 0:00 every day. After this, you go on Avançado (or something similar depending on the OS version) and selects Repetir a cada X minutos for 24 hours.

The key here is to find the advanced properties. If you are using the XP wizard, it will only offer the start of the advanced dialog box after you create the task.

In newer versions of Windows (7+):

  1. Double-click the task and a properties window will appear.
  2. Click on the tab Triggers.
  3. Double-click the trigger details and the Edit Trigger window will appear.
  4. On the panel Configurações avançadas, tick Repetir tarefa a cada xxx minutes and set Indefinidamente if you need.
  5. Finally, click on ok.

Taking advantage also follows how to run a php via Scheduler:

C: Path to php.exe -f "C: Path to file.php"

Source

  • It worked. Guilherme Nascimento’s answer: https://answall.com/questions/129554/executar-script-php-no-agendador-de-tarefas-do-windows. Thank you ;]

  • Yes there are several ways to do hehehe

  • No, it is the same as yours. Only it has the image that exemplifies more easily. In your case, it would be the "Program/script" = C:\xampp\php\php.exe and "Add arguments (optional)" = C:\xampp\htdocs\site\script.php... That is, it runs php.exe, and the argument that would be the script, and not the other way around. rs

1

Complementing Otto’s and Otto’s response link

How did you get the XAMPP:

ação

One must execute the php.exe, in this case I pulled from the XAMPP, and the argument would be caminho/script.php of the archive.

Browser other questions tagged

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