false, 'error' => 'Invalid id']); exit; } $script = SCRIPTS_DIR . '/' . $id; if (!file_exists($script)) { echo json_encode(['ok' => false, 'error' => 'Script not found: ' . $id]); exit; } $logFile = vv_job_log_path($id); $logDir = dirname($logFile); if (!is_dir($logDir)) mkdir($logDir, 0755, true); file_put_contents($logFile, "\n── " . date('Y-m-d H:i:s') . " ──────────────────────\n", FILE_APPEND); $flags = vv_job_flags($id); exec('nohup bash ' . escapeshellarg($script) . ($flags ? " $flags" : '') . ' >> ' . escapeshellarg($logFile) . ' 2>&1 true]);