我需要在 debian 上重新启动一个 go 应用程序进程,这需要运行以下 bash 文件:
systemctl stop go_service && other_command && systemctl start go_service
我尝试使用以下代码:
cmd := exec.Command("bash", scriptPath)
// Start the command asynchronously
if err := cmd.Start(); err != nil {
eError("Error starting command: %v\n", err)
return
}
但是第一个 bash 命令终止了该进程,并且它永远不会完成应该再次启动它的下一个命令
知道如何运行整个 bash 文件吗?
我通过使用以下方法解决了这个问题: systemctl 重新启动 go_service