Shutdown cron job and ongoing scrub task

I have a cron job like so:

midclt call system.shutdown

If a scrub task is going on, does the shutdown job wait for the scrub task to be finished?

No. The shutdown occurs as soon as the other parts of the OS are able to stop.

ZFS will resume the scrub as soon as the server boots up again, and imports the pool. This also applies to re-silvers, (disk replacements), RAID-Zx expansion(s), and asynchronous destroys.

Sun Microsystems designed ZFS so that as many operations as possible can be done live, with full access to the data. While a scrub, re-silver, RAID-Zx expansion or async. destroy will take I/O time, the actual performance impact will depend more on the storage devices and the server, than the background task.

I completely expect it to terminate the SCRUB and shut the system down.

EDIT: And possibly restart upon power up. :smile:

If you want to wait until the scrub completes, you should poll for the scrub status. You can use the API or the zpool status command to figure that out.

Or use the handy, dandy new option to zpool in the script just before shutdown;
zpool wait -t scrub POOL

2 Likes

Thanks for the insights! So the script would then be (I mean as a cron job):

zpool wait -t scrub POOL && midclt call system.shutdown

Right? I’m kind of a newbie with this…

More or less.

I prefer to write actual scripts even if it is just a line or 2. Partly because I can be verbose in things like path to commands and such. Then for clarity’s sake, I put only 1 command per line. But, to each their own.

That is one of the nice things about Unix OSes, lots of ways to accomplish the same result.

Right, I’m only starting with the discovery of scripting, so slowly I will sort things out. In the mean time, my data is very static (mostly media data, I only add something once in a while) so I can do with scrubs during the day (not every day) and shutdown during the night. Thanks for the pointers.