如何在script中確定mount有成功 - Linux

Iris avatar
By Iris
at 2015-05-17T17:09

Table of Contents

我有一個備份的指令,要在特定的分割區執行,所以第一步要確定mount。

雖然每次上線的的順序可能變掉,我可以用UUID解決這問題,然後我想到
用grep看mount有沒有備份資料夾的文字來確定mount有沒有成功:

test -n `mount|grep --color "on /backup type ext4"`
來看有沒有mount只會得到
-bash: test: 太多引數

這樣,看來test不能這樣玩。

所以我想請問有沒有辦法在script中檢查【特定的分割區mount到特定的位置】?

--
因為「其實呢,這場戰爭結束後,我就要回老家結婚了。」
而死亡的角色,據研究指出,背後的傷勢比前面還嚴重。

民明書房─《死亡FLAG──你不可不知的真實》

--
Tags: Linux

All Comments

Mary avatar
By Mary
at 2015-05-21T22:02
`mount|grep --color "on /backup type ext4"`
Ursula avatar
By Ursula
at 2015-05-24T17:36
這段不是結果對test不是字串...
他會變成test後面的參數
Suhail Hany avatar
By Suhail Hany
at 2015-05-27T09:01
啊....是這樣啊,那我該怎麼辦?
Andy avatar
By Andy
at 2015-05-31T20:34
用return code, "$?"
Carolina Franco avatar
By Carolina Franco
at 2015-06-01T05:26
直接用 if grep ... /proc/mounts; then...; fi
Tristan Cohan avatar
By Tristan Cohan
at 2015-06-03T02:41
test -n "`mount|grep --color "on /backup type ext4"`"

要如何改lsusb連結的硬體資訊?

David avatar
By David
at 2015-05-16T02:52
最近買了一塊totolink N150USM的無線網卡 結果Windows8.1抓的到也可以跑,但是lubuntu 15.04和RPi不行 找了老半天,結果看到lsusb的資訊: Bus 001 Device 005: ID 148f:7601 Ralink Technology, Corp. 可我的網卡 ...

Postfix自動轉信rule

Madame avatar
By Madame
at 2015-05-15T21:18
請問,postfix收到信時,能否判斷「有無附件」再作轉寄 假設今天寄來的信有附件,那自動轉寄給a使用者 若寄來的信沒有附件,那轉寄給b使用者 我找不到相關設定 感謝了 - ...

Ubuntu php5 source to deb

Lauren avatar
By Lauren
at 2015-05-15T16:26
已經在系統上面安裝了PHP 5.3的套件 但是現在需要使用到Thread的功能 所以需要將系統安裝的PHP 5.3做recomplie的動作 目前已經按照網路上的方法去下載PHP的source(apt-get source php5) 也去更改了debian/rules內的COMMON_CONFIG參 ...

關於 nginx 自動 urldecode問題

Sandy avatar
By Sandy
at 2015-05-15T00:39
請問一下各位, 最近在測試urlencode, urldecode, 發現nginx 自動幫我進行了urldecode, 不太清楚為什麼會自動處理, 我的配置是 nginx + php-fpm, nginx 反向代理 php-fpm 但是奇怪的是php本身沒有urldecode, nginx.conf也 ...

ubuntu 14.04 samba server的問題

Joseph avatar
By Joseph
at 2015-05-14T21:20
目前使用一ubuntu 14.04 透過samba作為檔案共享的server 碰到的問題是當使用windows8.1時,網路芳鄰找不到server,非得透過\\192.168.x.x才 找的到共享資料夾 然而雖然這個方法可以成功存取server上的檔案,但是一旦使用onedrive、google drive ...