매우 간단한 스크립트로 작업하고 있지만 어떤 이유로 인해 비동기 적으로 실행되는 것 같습니다.Bash 스크립트는 명령이 제대로 실행될 때까지 기다리지 않습니다.
singlePartDevice() {
# http://www.linuxquestions.org/questions/linux-software-2/removing-all-partition-from-disk-690256/
# http://serverfault.com/questions/257356/mdadm-on-ubuntu-10-04-raid5-of-4-disks-one-disk-missing-after-reboot
# Create single partition
parted -s "$1" mklabel msdos
# Find size of disk
v_disk=$(parted -s "$1" print|awk '/^Disk/ {print $3}'|sed 's/[Mm][Bb]//')
parted -s "$1" mkpart primary ext3 4096 ${v_disk}
parted -s "$1" set 1 raid on
return 0
}
singlePartDevice "/dev/sdc"
singlePartDevice "/dev/sdd"
#/dev/sdc1 exists but /dev/sdd1 does not exist
sleep 5s
#/dev/sdc1 exists AND /dev/sdd1 does also exist
수면 호출 전에 알 수 있듯이 스크립트는 일부만 작업을 마쳤습니다. parted가 작업을 성공적으로 완료 할 때까지 스크립트를 기다리게하려면 어떻게해야합니까?