【发布时间】:2019-03-05 10:09:35
【问题描述】:
我正在尝试在 PHP 中创建计划任务,但出现错误。
$input = 'schtasks /create /tn testSendMail /tr "php\"D:\wamp64\www\testScheduler\SchedulerURL.php"" /sc once /st 11:00';
$input = escapeshellcmd($input);
echo $input;
$execution = exec($input." 2>&1",$output);
var_dump($execution);
var_dump($output);
当我执行这个时,我得到:
array(2) { [0]=> string(93) "Erreur�: Le code XML de la t�che contient une valeur incorrectement format�e ou hors limites." [1]=> string(12) "(39,4):Task:" }
英文:
task XML code contains incorrect values format or is out of bounds
但是当我在终端上执行这个命令行时,它会创建一个计划任务。 我搜索过,但没有发现任何关于此的内容。
【问题讨论】:
-
你是否尝试从 php 中执行你的命令,它有效吗?
-
直接在cmd中执行就可以了
-
你试过
$output = shell_exec($input." 2>&1");吗? -
我得到与 shell_exec() 完全相同的错误:(
-
我试图用 notepad.exe 替换这个:"php\"D:\wamp64\www\testScheduler\SchedulerURL.php"" 但它也不起作用......
标签: php scheduled-tasks