The problem with that script is that. "zfs list | wc -l" will hang itself, will not give any result to the test and non-execution of the command.
Main Topics
Browse All TopicsI have an open solaris sun machine that encounters a zfs file system hang most of the time.
When we issue ZFS list , it hangs in there with no result. I have to execute "echo | format" or the "format" command to clear the hang.
I want to write a perl script that automates this every time the zfs filesystem hangs. The algorithm is below.
1. execute "zfs list | wc -l" and store the value in a scalar
2. check scalar is empty or not
3. if scalar value is empty, execute "echo | format " command
4. else exit
Want to set up this script as a crob job to run eveery minute
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
So it's really not:
1. execute "zfs list | wc -l" and store the value in a scalar
2. check scalar is empty or not
3. if scalar value is empty, execute "echo | format " command
4. else exit
It's:
1. execute "zfs list | wc -l"
2. if it hangs, execute "echo | format " command
4. else exit
Correct? How long of a wait before you consider it hung? A few seconds?
I tested it with a command that sleeps for 60 seconds (rather than zfs) and it worked, but YMMV. I'm fairly certain the timeout on the alarm will catch the hang, but I'm not so sure about the echo | format clearing your zfs problem via the perl script within a cron job. Give it a try and let us know.
BTW,forgot to include the shebang in the code I posted. If you're calling it directly, don't forget it-- like I did. :-)
Business Accounts
Answer for Membership
by: clockwatcherPosted on 2009-07-21 at 12:45:20ID: 24908533
Can you show the output of your 'zfs list | wc -l' in your two scenarios (one where it's working, the other where it's hung?). With it, you can probably get a more definitive answer, without it maybe this:
Select allOpen in new window