Reputation: 4612
On a Windows server, we have a task which runs occasionally, using "Scheduled Tasks" to control it. (best not to run it directly, since it might need to be run as a particular user, and the Scheduled Task configuration has all the appropriate passwords).
We'd like to control this via a PHP script, so that visitors to a website can request the task be run. Can PHP trigger the scheduled task? Including giving an error or taking no action if the task is already running.
Note: lockfiles etc. probably not a useful solution, since the task could fail/crash before completing
Upvotes: 0
Views: 405
Reputation: 2902
An easy way : let your task run all the time but do nothing till it finds some specific file, then delete it and do its job (then go back to wait).
You PHP (or whatever) script just have to create that file ...
Upvotes: 2
Reputation: 3421
If you have control of PHP environment, then you can directly execute external application within PHP using shell_exec and with additional parameters. Also you can use mutex like checks in the related task to prevent multiple executions.
Upvotes: 0