[Webinar] Streamline your web hosting managementRegister Today

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

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
Asked:
starhu
  • 2
  • 2
1 Solution
 
Julian HansenCommented:
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

Open in new window

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

Open in new window


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

Open in new window

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

Sorry for this.
0
 
Julian HansenCommented:
See my post above and let me know if that answers your question.
0
 
starhuAuthor Commented:
I have sent the post to my colleague: he will try it tomorrow, thank you very much
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

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