Linux 使用nohup挂起时出现nohup: failed to run command ‘PYTHONPATH=./‘: No such file or directory问题
在使用nohup指令挂起进程时,遇到了nohup: failed to run command 'PYTHONPATH=./': No such file or directory问题。
先上指令和错误:
nohup PYTHONPATH=./ python3 train.py >run.log 2>&1 &
报错:
nohup: failed to run command 'PYTHONPATH=./': No such file or directory
原因在于nohup需要给定一个明确的运行命令,而我这里使用的PYTHONPATH=./只是设置环境变量而不是实际的命令。
修改:
nohup bash -c "PYTHONPATH=./ python3 train.py" >run.log 2>&1 &
成功运行,另外可以使用tail -f指令在终端监控日志输出情况。
tail -f run.log
作者:再等五分钟