Paramiko does not keep my process running in the background (python)

Asked

Viewed 16 times

2

I have tried an automation where at the end of a looping routine access a server via SSH and open a new process.

But in the last part I can’t get the process started, follow the code:

from paramiko import SSHClient
import paramiko

class SSH:
    def __init__(self):
        self.ssh = SSHClient()
        self.ssh.load_system_host_keys()
        self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        self.ssh.connect(hostname=*IPSERVIDOR* ,username=*USUARIO*,password=*SENHA*)

    def exec_cmd(self,cmd):
        stdin,stdout,stderr = self.ssh.exec_command(cmd)
        if stderr.channel.recv_exit_status() != 0:
            print(stderr.read())
        else:
            print(stdout.read())

if __name__ == '__main__':
    ssh = SSH()
    ssh.exec_cmd("nohup cd *meu*/*diretorio*/python3 processo.py &")
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.