I use go exec ssh to execute "tail -f" on the remote server. Then I kill the process, but the "tail -f " still runs on the remote server.
What can I do to kill the "tail -f" process on the remote server?
My code is as follows:
package main
import (
"os/exec"
"github.com/astaxie/beego"
"time"
)
func main() {
var cmd = exec.Command("ssh","-t", "-p", "9122","deploy@123.com" ,"tail -f /log.out")
var err error
cmd.Start()
time.Sleep(time.Second*5)
err = cmd.Process.Kill() // when I kill this process, the remote server deploy@123.com still has 'tail -f /log.out' running
beego.Error(err)
}
Just add one more "-t" in the arguments.
var cmd = exec.Command("ssh","-t", "-t", "-p", "9122","deploy@123.com" ,"tail -f /log.out")
For more information, refer this link