Trying to make a resync script

Good Morning,

I'm trying to automate the resync process after a mirror replacement on Solaris. To avoid resyncing all the drives at once, I'm trying to use metastat for each drive to determine if the drive is still resyncing or if it is done (Okay). The following test lines seem to always show false, while removing the "!" always shows true. In other words, it doesn't translate "Resyncing" or Okay" into true/false results:

While !(metastat d1 | grep "Resyncing" | wc -l | cut -f1 -d' '; do echo ResyncFound; sleep 5; done
While !(metastat d1 | grep "Okay" | wc -l | cut -f1 -d' '; do echo Okay; sleep 5; done

Any ideas on how to translate "Resyncing" into true?

Welcome to the forum.

Did you consider evaluating grep 's exit code?
And, I'm not sure what that construct be: !( , even more when the closing parenthesis seems to be missing? Shouldn't while be lower case?

1 Like

Thanks- I'm using Solaris 9 which doesn't seem to recognize exit code option

-q

. Sorry- forgot to mention that. What I have up there is an attempt to simulate that.

The

!

will invert the true/false. I think that part is working actually. The cap and the missing closing parenthesis are typos here. Sorry again.

Long story short- I just want to be able to read metastat somehow, and if a drive is still resyncing, wait until its okay, then move to the next drive, and so on.

Yes it does. You need to use /usr/xpg4/bin/grep for that..

1 Like

Thanks.. That works!