shell中任务递交后修改循环配置文件效果

 

001、 投递该任务

(base) [b20223040323@admin1 test]$ ls
a.txt  record.sh
(base) [b20223040323@admin1 test]$ cat a.txt    ##  循环配置文件
1       1000000000
2       500000000
(base) [b20223040323@admin1 test]$ cat record.sh  ## 测试程序
#!/bin/bash

cat a.txt | while read {i,j}
do
        seq $j | tac > $i.txt
        echo $i done
done
(base) [b20223040323@admin1 test]$ bash record.sh

 

002、在第一行的循环未执行完的情况下删除循环配置文件a.txt的第二行(另一个终端窗口操作), 观察程序是否执行第二行的循环

(base) [b20223040323@admin1 test]$ ls
1.txt  a.txt  record.sh
(base) [b20223040323@admin1 test]$ cat a.txt
1       1000000000
2       500000000
(base) [b20223040323@admin1 test]$ sed '$d' a.txt -i
(base) [b20223040323@admin1 test]$ cat a.txt
1       1000000000
(base) [b20223040323@admin1 test]$ ls
1.txt  a.txt  record.sh

 

003、等待程序运行完,观察结果文件

 

(base) [b20223040323@admin1 test]$ ls             ## 两行的循环结果文件都生成 
1.txt  2.txt  a.txt  record.sh
(base) [b20223040323@admin1 test]$ head -n 2 1.txt
1000000000
999999999
(base) [b20223040323@admin1 test]$ head -n 2 2.txt
500000000
499999999

 

004、小结: 

任务一旦投递,修改循环配置文件,对整个程序无影响(在shell终端, slurm任务系统(经测试)均适用)。

 

posted @ 2023-05-13 08:52  小鲨鱼2018  阅读(34)  评论(0编辑  收藏  举报