i just need safety process. nfs mount, data rsync, and shell ended.
rmv=`cat /proc/mounts | grep /mnt/nfs | cut -d: -f2 | awk '{print $2}'`
if [ $rmv != $@ ]; then
echo "not mounted"
else if umount /mnt/nfs > /dev/null 2>&1 || /bin/false; then
umount successed
else
device is busy"
fi
fi
is working but...
'[' /mnt/nfs '!=' ']'
[: /mnt/nfs: unary operator expected
i got using "$@" i think i was wrong expression. need other ways
There are actually quite a few flaws in your initial script, and some unnecessary use of code/commands.... does this do what you want? Note - it's untested, but I think it's syntactically correct.
rmv=$(awk -F"[: ]+" '/\/mnt\/nfs/{print $2}' /proc/mounts)
if [ $rmv == "" ]; then
echo "not mounted"
else
if umount /mnt/nfs > /dev/null 2>&1 ; then
echo "umount succeeded"
else
echo "device is busy"
fi
fi
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.