在尝试运行Python35脚本时使用nohup?

时间:2017-10-30 13:25:15

标签: python linux bash putty

我试图在linux服务器上运行python程序,使用putty控制台从通过WinSCP上传到服务器的文件夹中拉出程序和包。当我使用命令正常运行程序时:

python35 program.py

它完美运作并开始运行。问题是当我的计算机关闭且putty窗口消失时,我需要在服务器上运行程序。

我读到你可以使用nohup命令执行此操作,但每当我运行时:

nohup python35 program.py &

它返回:

ignoring input and appending output to `nohup.out'
nohup: failed to run command `python35': No such file or directory

此时程序没有运行,并且在WinSCP上创建了一个空的nohup.out文件。

为什么会这样?我该如何解决?到目前为止,我还没能在SO上找到任何等效的错误。

1 个答案:

答案 0 :(得分:1)

如上面评论中所述,python35是shell别名。由于nohup在子shell中运行给定命令,因此父shell进程中定义的别名将不可用。

使用以下命令:

nohup /opt/rh/rh-python35/root/usr/bin/python program.py &