This commit is contained in:
parent
7e93bee4fa
commit
37924aa27d
|
|
@ -3,37 +3,39 @@
|
||||||
* 执行多个webman相关的nohup命令
|
* 执行多个webman相关的nohup命令
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 定义要执行的命令列表
|
/**
|
||||||
|
* 批量启动 Webman 进程的 PHP 脚本
|
||||||
|
* 功能:执行多个 nohup 命令,启动指定的 Webman 任务并后台运行
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 定义需要执行的命令列表
|
||||||
$commands = [
|
$commands = [
|
||||||
'nohup php webman applysmstemp &',
|
'nohup php webman applysmstemp &',
|
||||||
'nohup php webman birthdaygiftsms &',
|
'nohup php webman birthdaygiftsms &',
|
||||||
'nohup php webman rabborderprint &',
|
'nohup php webman rabborderprint &',
|
||||||
'nohup php webman rabbproductupdate &',
|
'nohup php webman rabbproductupdate &'
|
||||||
];
|
];
|
||||||
//$commands = [
|
|
||||||
// 'php webman applysmstemp',
|
|
||||||
// 'php webman birthdaygiftsms',
|
|
||||||
// 'php webman rabborderprint',
|
|
||||||
// 'php webman rabbproductupdate',
|
|
||||||
//];
|
|
||||||
echo "开始执行命令...\n";
|
|
||||||
|
|
||||||
// 遍历并执行每个命令
|
// 执行命令并输出结果
|
||||||
foreach ($commands as $index => $command) {
|
echo "开始启动 Webman 进程...\n";
|
||||||
echo "执行第 " . ($index + 1) . " 条命令: {$command}\n";
|
echo "----------------------------------------\n";
|
||||||
|
|
||||||
// 执行命令
|
foreach ($commands as $index => $cmd) {
|
||||||
$output = [];
|
$commandNum = $index + 1;
|
||||||
$returnVar = 0;
|
echo "执行命令 {$commandNum}: {$cmd}\n";
|
||||||
exec($command, $output, $returnVar);
|
|
||||||
|
|
||||||
// 检查命令执行结果
|
// 执行命令(使用 shell_exec 执行并获取输出)
|
||||||
if ($returnVar === 0) {
|
$output = shell_exec($cmd . ' 2>&1'); // 重定向错误输出到标准输出
|
||||||
echo "命令执行成功\n";
|
|
||||||
|
// 检查命令是否成功执行(nohup 后台命令通常返回空,但可通过进程是否存在验证)
|
||||||
|
if ($output === null) {
|
||||||
|
echo "命令 {$commandNum} 启动成功(后台运行)\n";
|
||||||
} else {
|
} else {
|
||||||
echo "命令执行失败,返回码: {$returnVar}\n";
|
echo "命令 {$commandNum} 执行输出: {$output}\n";
|
||||||
echo "输出信息: " . implode("\n", $output) . "\n";
|
|
||||||
}
|
}
|
||||||
|
echo "----------------------------------------\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "所有命令已提交执行\n";
|
echo "所有命令已执行完毕。\n";
|
||||||
|
echo "可通过 'ps aux | grep webman' 查看运行中的进程。\n";
|
||||||
|
echo "可通过 'kill [进程ID]' 停止指定进程。\n";
|
||||||
Loading…
Reference in New Issue