我的系統會運行以下Function:
public function waha_send_wts_group_message() {
        if ($this->ion_auth->logged_in() && $this->ion_auth->is_admin()) {
    
            $batchSize = 100;
            $delay = 5;
        
            $users = json_decode($this->input->post('users'));
            $message = $this->input->post('title') . "\n" . $this->input->post('message') . "\n" . $this->input->post('footer');
            $type = $this->input->post('message_template_type');
        
            unset($_POST["users"]);
        
            // 準備上傳資料夾
            $targetDir_Docs = "uploads/whatsapp/docs/";
        	$targetDir_IMG = "uploads/whatsapp/img/";
        	if (!is_dir($targetDir_Docs)) {
                mkdir($targetDir_Docs, 0777, true);
            }
            if (!is_dir($targetDir_IMG)) {
                mkdir($targetDir_IMG, 0777, true);
            }
        
            $_file = null; // 上傳檔案資訊
        
            if ($type == "IMAGE" && !empty($_FILES["update_image"]["name"])) {
                $_path = $_FILES['update_image']['tmp_name'];
                $_filetype = pathinfo($_FILES['update_image']['name'], PATHINFO_EXTENSION);
                $_name = date("YmdHis") . "_group_" . preg_replace('/[^a-zA-Z0-9_\-\.]/', '', $_FILES['update_image']['name']);
                $_data = file_get_contents($_path);
                if (is_uploaded_file($_path)) {
                    $return = file_put_contents($targetDir_IMG . $_name, $_data);
                    if ($return !== false) {
                        $_file = [
                            "name" => $_name,
                            "url" => base_url($targetDir_IMG . $_name)
                        ];
                    } else {
                        // 上傳失敗
                        $this->response['error'] = true;
                        $this->response['message'] = "圖片上傳失敗，請重試";
                        print_r(json_encode($this->response));
                        return;
                    }
                }
            }
        
            if ($type == "DOCS" && !empty($_FILES["update_doc"]["name"])) {
                $_path = $_FILES['update_doc']['tmp_name'];
                $_filetype = pathinfo($_FILES['update_doc']['name'], PATHINFO_EXTENSION);
                $_name = date("YmdHis") . "_group_" . preg_replace('/[^a-zA-Z0-9_\-\.]/', '', $_FILES['update_doc']['name']);
                $_data = file_get_contents($_path);
                if (is_uploaded_file($_path)) {
                    $return = file_put_contents($targetDir_Docs . $_name, $_data);
                    if ($return !== false) {
                        $_file = [
                            "name" => $_name,
                            "url" => base_url($targetDir_Docs . $_name)
                        ];
                    } else {
                        $this->response['error'] = true;
                        $this->response['message'] = "文件上傳失敗，請重試";
                        print_r(json_encode($this->response));
                        return;
                    }
                }
            }
        
            // 紀錄發送任務到 logs (取決於你 Logs_model 實作)
            $this->load->model('Logs_model');
            $msgLogID = $this->Logs_model->add_logs([
                "component" => "Message",
                "type" => "Send Group Message",
                "status" => "Executing",
                "uid" => $this->session->userdata('user_id'),
                "username" => $this->session->userdata('username'),
                "request" => $_POST,
                "response" => ['message' => 'Executing'],
                "attachment" => $_file['url'] ?? null,
                "c_total_user" => count($users),
                "batchSize" => $batchSize,
                "batchCount" => ceil(count($users) / $batchSize)
            ]);
        
            // 封裝參數給 CLI，注意用 escapeshellarg 防止命令注入
            /*
            $msgLogID_esc = escapeshellarg($msgLogID);
            $users_json = escapeshellarg(json_encode($users));
            $message_esc = escapeshellarg($message);
            $type_esc = escapeshellarg($type);
            $file_json = escapeshellarg(json_encode($_file));
            */
        
            // PHP CLI 執行指令
            $url = "https://hkccsa.citrusinno.com/admin/notification_cli/send_batch";
            
            // 將參數做 json 或 key=value 格式
            $postFields = [
                'msgLogID' => $msgLogID,
                'message' => $message,
                'type' => $type,
                'users' => json_encode($users),
                'file' => json_encode($_file),
            ];
            
            // 轉成 curl 命令參數字串
            $postData = json_encode($postFields);
            
            
            //$postData = '{"msgLogID":51,"message":"\nTesting\n","type":"TEXT","users":"[{\"memberID\":\"99999990\",\"tel\":\"66868260\"}]"}';
            
            
            $cmd = "curl --silent --max-time 604800 --connect-timeout 604800 -H \"X-API-KEY: RektqczqKGTQaXwbiwnzRDWNhOdHgUmh\" -H \"Content-Type: application/json\" -X POST -d '{$postData}' {$url} > /dev/null 2>&1 &";

            
            $output = [];
            $return_var = 0;
            exec($cmd);
        
            $this->response['error'] = false;
            $this->response['message'] = "訊息發送請求已提交至伺服器處理。";// . "\nCMD: " . $cmd . "\nOUTPUT: " . implode(",", $output) . "\nRETURN: " . $return_var;
            print_r(json_encode($this->response));
            return;

        } else {
           redirect('admin/login', 'refresh');
        }
    }

當中發現運行curl指令時會在特定時間後中止運行，使後續的程序中斷了，請問有甚麼方法可以確保程式可以持續運行而不會出現Timeout或中斷情況?