Files
p_ysk/start_webman_commands.php
2025-10-17 10:28:53 +08:00

41 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* 执行多个webman相关的nohup命令
*/
/**
* 批量启动 Webman 进程的 PHP 脚本
* 功能:执行多个 nohup 命令,启动指定的 Webman 任务并后台运行
*/
// 定义需要执行的命令列表
$commands = [
'nohup php webman applysmstemp &',
'nohup php webman birthdaygiftsms &',
'nohup php webman rabborderprint &',
'nohup php webman rabbproductupdate &'
];
// 执行命令并输出结果
echo "开始启动 Webman 进程...\n";
echo "----------------------------------------\n";
foreach ($commands as $index => $cmd) {
$commandNum = $index + 1;
echo "执行命令 {$commandNum}: {$cmd}\n";
// 执行命令(使用 shell_exec 执行并获取输出)
$output = shell_exec($cmd . ' 2>&1'); // 重定向错误输出到标准输出
// 检查命令是否成功执行nohup 后台命令通常返回空,但可通过进程是否存在验证)
if ($output === null) {
echo "命令 {$commandNum} 启动成功(后台运行)\n";
} else {
echo "命令 {$commandNum} 执行输出: {$output}\n";
}
echo "----------------------------------------\n";
}
echo "所有命令已执行完毕。\n";
echo "可通过 'ps aux | grep webman' 查看运行中的进程。\n";
echo "可通过 'kill [进程ID]' 停止指定进程。\n";