This is related to an effort to shutdown a seldom used server if there are no SSH connections or open files.
How can I determine in a shell script (cron job on a Linux box) if any of the current samba shares have any open files?
If your samba server is configured to use file locking which is probably is, I suppose you could use 'smbstatus -L' to list the locks and then grep the output for the type of lock you're looking for (EXCLUSIVE, BATCH) if you knew you only cared about certain kinds of locks.
smbstatus -L | grep EXCLUSIVE
and then test against the return value ($?) in the cron job script.
Unfortunately, I don't know enough about the types of locks to know if this is a suitable catch-all method or not.
I would probably use the lsof command to determine what files are in use on the share.
cense's answer is good, and his thing about the locks applies to this answer. Samba also allows read only status (I think it shows up as RD_ONLY), and also displays entries for directories that are open in Windows Explorer, so you have to decide what kind of locks you want to ignore/focus on.
I believe the output of
To the best of my knowledge (No access to a Samba server right now), if you have a Samba share mounted in Windows,