Running process in the background

前端 未结 5 915
日久生厌
日久生厌 2020-12-17 03:24

I am finding hard to run a process at background using paramiko. I used :

stdin, stdout, stderr = ssh.exec_command(\'executefile.py &\') 
5条回答
  •  时光说笑
    2020-12-17 04:13

    I tried transport class and it was really great. Here's the code I used:

    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(hostname = "host_ip", username = "un"], password = "up")
    channel = ssh.get_transport().open_session()
    pty = channel.get_pty()
    shell = ssh.invoke_shell()
    shell.send("cd /my/directory/; nohup ./exec_name > /dev/null 2>&1 &\n")
    

    But I still don't know how to kill it using python scripts; I have an open question about it here.

    EDIT 1:

    I have solved my problem about killing the process somehow; you can check it.

提交回复
热议问题