prun.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # !/bin/bash
  2. SEND_THREAD_NUM=2
  3. tmp_fifofile="/tmp/$$.fifo" # 脚本运行的当前进程ID号作为文件名
  4. mkfifo "$tmp_fifofile" # 新建一个随机fifo管道文件
  5. exec 6<>"$tmp_fifofile" # 定义文件描述符6指向这个fifo管道文件
  6. rm $tmp_fifofile
  7. for i in $(seq 1 $SEND_THREAD_NUM)
  8. do
  9. echo # for循环 往 fifo管道文件中写入 $SEND_THREAD_NUM 个空行
  10. done >&6
  11. CUTOFF_TIME=1000
  12. instance_dirs="bio col fb inf int rec ret sci soc tec web"
  13. all_results_dir=$1
  14. graph_dir="/home/jkunlin/all_graphs/graphs"
  15. if [ -d "$all_results_dir" ]
  16. then
  17. echo "warning: $all_results_dir exist"
  18. exit 0
  19. fi
  20. mkdir "$all_results_dir"
  21. for seed in $(seq 1 10)
  22. do
  23. echo "************* $seed *****************"
  24. for ins_dir in $instance_dirs
  25. do
  26. echo "$ins_dir"
  27. res_dir="$all_results_dir"/"$ins_dir"
  28. if [ ! -d "$res_dir" ]
  29. then
  30. mkdir "$res_dir"
  31. fi
  32. find "$graph_dir/$ins_dir" -maxdepth 1 -mindepth 1 |
  33. while read instance
  34. do
  35. read -u 6
  36. {
  37. instance=$(basename "$instance")
  38. res_dir="$res_dir"/"$instance"
  39. if [ ! -d "$res_dir" ]
  40. then
  41. mkdir "$res_dir"
  42. fi
  43. res_file="$res_dir"/"$instance"_"$seed"
  44. echo "$graph_dir/$ins_dir/$instance" "$seed" "$CUTOFF_TIME" > "$res_file"
  45. echo >&6
  46. } &
  47. done
  48. done
  49. done
  50. exit 0