[Webinar] Streamline your web hosting managementRegister Today

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 948

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

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
starhu
• 2
• 2
1 Solution

Commented:
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

ConsultantCommented:
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 Commented:
As you may have already noticed it instead of "Task Manager" I meant "Task Scheduler".

Sorry for this.
0

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

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

## Featured Post

• 2
• 2
Tackle projects and never again get stuck behind a technical roadblock.