Solved

# How to run a Php task periodically on Windows server?

Posted on 2012-08-21
793 Views
Hello,

I need to to run a Php task periodically on Windows server.
Preferably the Php script would write the task in the Task Manager.

Thank you
0
Question by:starhu

LVL 49

Accepted Solution

Use the scheduler (AT) to schedule the task.
Preferably the Php script would write the task in the Task Manager.

Not sure what you mean by this Task Manager is a monitoring utility that gives information on what apps / services are running on a computer and what their resource utilisation is. Applications executed will appear their by default - you don't write to it.

With the at command you can either get it to run your script directly or use it to run a batch file. (Assumes relevant scripts are in E:\temp - change as required - you need to give full paths to all scripts because the scheduler will not start in the folder where they are stored unless you configure it to).

E:\temp\dophpscript.bat
php e:\temp\phpscript.php

e:\temp\phpscript.php
<?php
$test ="This is a test"; file_put_contents('e:\temp\testoutput.txt',$test);
?>


Either create from command line or through GUI
AT command from command line (assumes bat file is in E:\temp
at 9:00am /every:tuesday e:\temp\dophpscript.bat

0

LVL 34

Expert Comment

Just use task scheduler to execute:
c:\php\php.exe c:\path\to\your\script.php

And replace the first part with the appropriate path to the php.exe on your system.
0

Author Comment

Sorry for this.
0

LVL 49

Expert Comment

See my post above and let me know if that answers your question.
0

Author Comment

I have sent the post to my colleague: he will try it tomorrow, thank you very much
0

## Featured Post

### Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…