Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, I create following bash script part to check open files on my remote server. Code: ssh -T $S_LOGIN <<EOI open_File=`lsof +D /x01/files/scripts/ |grep -v "DIR"|wc -l` echo "open ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    26

    Lightbulb check open file using lsof


    Hi all,

    I create following bash script part to check open files on my remote server.
    Code:
    ssh -T $S_LOGIN <<EOI
    
    	open_File=`lsof +D /x01/files/scripts/ |grep -v "DIR"|wc -l`
    	
    	echo "open file count : \$open_File"
        if ["$Open_File" -gt 1]; then
            echo "Warning:Folder have following open files"
    		lsof +D /x01/files/scripts |grep -v "DIR"
        else
            echo "No Open files ";   	
    		
        fi
     
    exit;
    EOI
    but here wc -l value not assign to $open_File variable it print as 0 (There are some open files in server ). please give some help for this or please give some proper way to check open files.
    Last edited by charith; 12-12-2011 at 04:34 PM. Reason: update

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    $Open_File and $open_File are not the same variable
    linux user # 503963

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •