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