PHP and Shell checks whether SAMBA and NFSServer exist, sambanfs. PHP and Shell check whether SAMBA and NFSServer exist. sambanfs usually uses etcfstab to process the mounting settings, and then uses mount-a to re-confirm the mounting, it is best to check whether SAMBA and NFS Server exist in the scheduling PHP and Shell, sambanfs
The mount settings are usually handled through/etc/fstab, and then the mount-a is used to re-confirm the mount, it is best to execute mount-a when the mounting directory is used by the scheduling program. The mount directory will not be automatically replied after the disconnection. the Timeout of mount-a is actually quite long, especially when the Server does not exist, it is best to use the corresponding client to check whether the server exists.
The client that checks NFS can use showmount for processing. the installation method on Ubuntu is as follows:
The code is as follows:
Sudo aptitude install nfs-common
The SAMBA client uses smbclient. the installation method on Ubuntu is as follows:
The code is as follows:
Sudo aptitude install smbclient
Process for checking whether the NFS Server exists
Check in Shell mode
The code is as follows:
# Use the client to check whether the server exists
/Sbin/showmount 192.168.0.6>/dev/null 2> & 1
If ["j $? "! = "J0"]; then
Echo "NFS Server is not exist"
Exit 1
Fi
# Reconfirm mounting
Mount-a>/dev/null 2> & 1
If ["j $? "! = "J0"]; then
Echo "NFS Server mount failed"
Exit 1;
Fi
Check in PHP mode
The code is as follows:
/* Use the client to check whether the server exists */
$ State = shell_exec ('/sbin/showmount 192.168.0.6>/dev/null 2> & 1; echo $? ');
If (trim ($ state )! = '0 '){
Echo "NFS Server is not exist ";
Exit;
}
/* Re-confirm mounting */
If (shell_exec ('Mount-a 2> & 1 ')){
Echo "NFS Server mount failed"
Exit;
}
Check the process of SAMBA Server
Check in Shell mode
The code is as follows:
# Use the client to check whether the server exists
Smbclient-NL // 192.168.0.6>/dev/null 2> & 1
If ["j $? "! = "J0"]; then
Echo "SAMBA Server is not exist"
Exit 1
Fi
# Reconfirm mounting
Mount-a>/dev/null 2> & 1
If ["j $? "! = "J0"]; then
Echo "SAMBA Server mount failed"
Exit 1;
Fi
Check in PHP mode
The code is as follows:
/* Use the client to check whether the server exists */
$ State = shell_exec ('smbclient-NL // 192.168.0.6>/dev/null 2> & 1; echo $? ');
If (trim ($ state )! = '0 '){
Echo "SAMBA Server is not exist ";
Exit;
}
/* Re-confirm mounting */
If (shell_exec ('Mount-a 2> & 1 ')){
Echo "SAMBA Server mount failed"
Exit;
}
Whether the volume Server exists. sambanfs usually uses/etc/fstab to process the mounting settings, and then uses mount-a to re-confirm the mounting. it is best to schedule the mounting...