后台脚本 + nohup
- 写一个脚本,包含需要创建的环境和想运行的程序
1 | export PATH="/code/miniconda3/bin:$PATH" |
运行
nohup bash run_pulid.sh > run.log 2>&1 & disown
查看进度:
tail -f run.log
,或者直接看run.log文件杀死进程:
ps -ef | grep train.py
pkill -f train.py
tmux
创建新会话
tmux new -s pulid
在这个会话里运行
export PATH=”/code/miniconda3/bin:$PATH”
source /code/miniconda3/etc/profile.d/conda.sh
conda activate pulid
python train.py之后恢复一下会话就行:
tmux attach -t pulid
查看所有会话:
tmux ls