문제

So i am writing a script to call a process 365 times and they should run in 10 batches, so this is something i wrote but there are multiple issues - 1. the log message is not getting written to the log file, i see the error message in err file 2. there is this "Command not found" error I keep getting from the script for the line process. 3. even if the command doesnt succeed, still it doesn't print FAIL but prints success

#!/bin/bash

set -m
FAIL=0

for i in {1..10}
do
  waitPIDS=()
  j=$i
  while [ $j -lt 366 ]; do

  exec 1>logfile
  exec 2>errorfile

 `process $j &`

  waitPIDS[${#waitPIDS[@]}]=$!
  j=$[$j+1]

done

for jpid in "${waitPIDS[@]}"
do
  echo $jpid
  wait $jpid
  if [[ $? != 0 ]] ; then
    echo "fail"
  else
    echo "success"
  fi
done

done

What is wrong with it ?

thanks!

도움이 되었습니까?

해결책

At the very least, this line:

 `process $j &`

Shouldn't have any backticks in it. You probably just want:

 process $j &

Besides that, you're overwriting your log files instead of appending to them; is that intended?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top