1、使用bash脚本

😜 👍👌

1.1 1️⃣ nohup + nohup方式1️⃣

#!/bin/bash
for num in 1 2 3 4 5
do
    nohup python test.py --num $num >test{$num}.log &
    wait
done
nohup bash start.sh

这样的方式可以啊。这样会让里面的Python命令一条接着一条的执行,上一条执行完了,下一条才会开始执行。

1.3 ❌ 👎 仅wait方式 或者 仅&方式 2>&1 &方式 ,

#!/bin/bash
nohup python main.py --dataset yelp2018 --lr 0.001 --batch_size 2048 --gpu_id 2  >yelp_dim_topk0.1.log 
wait

nohup python main.py --dataset amazon --lr 0.001 --batch_size 2048 --gpu_id 2  >amazon_dim_topk0.1.log &
nohup python main.py --dataset yelp2018 --lr 0.001 --batch_size 2048 --gpu_id 2  >yelp_dim_topk0.1.log 2>&1 &
nohup python main.py --dataset amazon --lr 0.001 --batch_size 2048 --gpu_id 2  >amazon_dim_topk0.1.log 2>&1 &

这样的方式不行。这样会一下子把所有的进程都挂上去,让他们同时执行,而不是一条接着一条执行。

1.4 & wait方式

#!/bin/bash
nohup python main.py --dataset yelp2018 --lr 0.001 --batch_size 2048 --gpu_id 2  >yelp_dim_topk0.1.log &
wait

nohup python main.py --dataset amazon --lr 0.001 --batch_size 2048 --gpu_id 2  >amazon_dim_topk0.1.log &
wait

1.5 批量删除指定进程

ps -aux | grep start_MutliBPR.sh | grep -v grep | awk '{print $2}' | xargs -r kill -9
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐