LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-25-2014, 04:49 AM   #1
Kingsters
LQ Newbie
 
Registered: Feb 2014
Posts: 2

Rep: Reputation: Disabled
Linux SSH Server File status


I have a script to find a files in SSH server on every hour. The source files in ssh server which will comes from another server. My Script will have capability to check whether the files are available or not in particular directory.

How to find the file status?
Suppose the files are huge still copying status in source server. Gow to check the files are not fully copied in server?

Please help me on this..
 
Old 02-25-2014, 05:31 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,474

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
You can use lsof /path/to/the/file to check if your file is in use by any other process, if it's not being used by a process like rsync/scp then you can assume it's fully copied.
 
Old 02-25-2014, 06:10 AM   #3
Kingsters
LQ Newbie
 
Registered: Feb 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
thank you.. I will check it and let you know sson.
 
Old 02-25-2014, 09:59 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It would be better to have the process sending the data put it in a different directory (same disk). That way even if the transfer of the file is interrupted (and thus either incomplete or corrupted) you wouldn't try to process it.

Once the file has arrived (and presumably verified/validated), use "mv" to put it in the directory
you will look for it.

Directory operations are atomic...

File transfer is not... and just because a process isn't currently using the file doesn't mean the file is complete...

Oh, and for processing the file - first move it out of the directory... You woudn't want to be in the middle of processing a file and have it change out from under you....

Last edited by jpollard; 02-25-2014 at 10:01 PM.
 
Old 02-28-2014, 12:36 PM   #5
byau
Member
 
Registered: Sep 2009
Location: Los Angeles, CA
Posts: 33

Rep: Reputation: 5
If you don't mind a bit of extra scripting, you can run md5sum hash on remote side, copy those over first, then as your files are transferring md5sum hash on the local side and once they match, you know your files are done copying

Also a very good idea, because even if the file is done copying, you won't know if they are pristine copies until you run the md5sum hash anyway

Fresh in my mind, just wrote a blog post about this and why md5sum hash is a very valuable tool

http://geekswing.com/geek/the-magic-...sha-1-vintage/
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Server Hung due to hda: status timeout: status=0xd0 { Busy } adamalic Linux - Enterprise 3 12-15-2011 01:27 PM
Exprot config file on Linux (proxy server) and using SSH, and anything like this rosy84 Linux - Networking 2 07-13-2011 11:24 PM
Server status command output getting dumped to smtp server instead of a file VC0041098 Linux - Server 2 05-26-2010 11:00 AM
move file from server to server using ssh (putty), plz help niitpro Linux - Newbie 2 02-07-2008 09:43 PM
How to restart & check status of ssh server bostonantifan Ubuntu 3 10-30-2007 11:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration