简体   繁体   中英

Launch scheduled task from script

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

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 ...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM