[kwlug-disc] Sleep until command is finished
Charles M
chaslinux at gmail.com
Thu Jan 6 13:06:13 EST 2022
My bash-foo is very rusty. I'm trying to run smartmontools to check a
drive using the short test option (which usually takes less than 2
minutes to complete). After the command is finished I want to then
probe for the results of the test. Here's my script:
#!/bin/bash
sudo smartctl -t short /dev/sda &
while ps -p $PPID > /dev/null; do sleep 1; done;
sudo smartctl -l selftest /dev/sda | grep "# 1"
This seems to hang after smartctl starts the short test. I've waited
well after the time smartctl should finish and it doesn't seem to
finish and run the second smartctl command.
Thanks,
Charles
More information about the kwlug-disc
mailing list