问题描述
利用python的Paramiko模块 SSH连接远程AIX系统,无法对DB2数据库进行后台执行sql文件,代码如下:
# client是 paramiko的SSHClient实例
client.exec_command("db2 -tvf test.sql > test.log 2>&1 &")
提示错误如下:
DB21018E A system error occurred. The command line processor could not continue processing.
不使用后台执行,则能够成功执行:
client.exec_command("db2 -tvf test.sql") # 这样能够执行,并得到结果
怀疑 SSHClient 关闭连接时,对进程发送了中断信号,于是做下面的尝试,也是报DB21018E。
client.exec_command("nohup db2 -tvf test.sql > test.log 2>&1 &")
想实现 后台执行 sql文件,但是不得其解,望各位大神指点,谢谢。
试试这个
nohup xxxxx >/dev/null 2>log &