Disconnecting the network SMB drive

barmaglot
New Contributor

Hello!

Mac (MBP 2020, MacOS 11.5, 11.6) randomly disconnect a network drive mapped to the DFS root. Disconnection occurs regardless of the connection via LAN or WiFi.

A script was written that checks for the presence of a disk and, if it is absent, connects it back. But after that, in some cases, folders in the DFS root are visible, but they are empty. After 30 minutes or more, the contents of the folders may appear.

With a manual connection, the same thing happens. Can connect normally, can connect with empty folders.

What could be the reason for spontaneous disconnection from the server and how to avoid it? And why does it take so long to read the contents of network folders?

1 REPLY 1

barmaglot
New Contributor

Wrote a script to distribute by policy. The script works, but it may need to be optimized. Any ideas?

set dn to "smb://server/shre"
set sn to "share"

repeat while (1 = 1)
      tell application "Finder"
             if not (exists file "~/fl" as POSIX file) then
                   #           display dialog "no flag"
                   do shell script "echo 1 > ~/fl"
                   if not (exists file "/Volumes/share/.DS_Store" as POSIX file) then
                          do shell script "echo lost >> ~/Documents/log.txt"
                          do shell script "date >> ~/Documents/log.txt"
                         
                          repeat while (disk sn exists)
                                eject disk sn
                                delay 1
                          end repeat
                          set p to do shell script "ping -c 1 10.10.10.10 | grep transm"
                          repeat while not (p = "1 packets transmitted, 1 packets received, 0.0% packet loss")
                                set p to do shell script "ping -c 1 10.10.10.10 | grep transm"
                                delay 1
                          end repeat
                          mount volume dn
                          do shell script "echo return >> ~/Documents/log.txt"
                          do shell script "date >> ~/Documents/log.txt"
                          do shell script "echo ------- >> ~/Documents/log.txt"
                         
                   end if
                   do shell script "rm ~/fl"
             end if
      end tell
      delay 60
end repeat