LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 07-27-2006, 11:41 AM   #1
lohrpr
LQ Newbie
 
Registered: Jul 2006
Posts: 2

Rep: Reputation: 0
How to Deternine file status


All,

I would consider myself a mid-linux user. I am an Oracle DBA and have done a few installs of Oracle on linux so I am familiar with some scripting. I need a script that will move files from a directory to another directory. The catch is the first directory is a directory that many users will FTP files to, after they FTP the file, a CRON job will process the files. Some of these files will be large and may take some time to transport. I have to process the files within 2 min after the file transfer completes. I have scripts that can move files based on date or even time. My issue is if I use “ls” to find out if there are any files in the directory it will show me files that have not yet completed the file transport. Basically, I need a script that will look at a folder and determine which files have completed the file transport and not the ones that are in the middle of transport.

Also I will need to move this to a solaris box in production so I need a command that will work on both.

Any help would be appreciated,

Thanks
 
Old 07-27-2006, 01:13 PM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
I'm not sure about that, but shouldn't lsof do the trick?
 
Old 07-27-2006, 01:51 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

See: http://www.linuxquestions.org/questi...52#post2353652
 
Old 07-27-2006, 03:42 PM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
By "process the file" do you simply mean "move it to another directory?" If so, you could use "ln" and "rm" cronjobs.

The following assumes you don't care if the in-transit file appears in the destination while it's still being transferred, your source files are uniquely named, the source and destination directories are on the same filesystem, and that only plain files exist in the source directory. These are a big assumptions since you didn't really tell us any details of your task. This example is for the simplest scenerio I can imagine, but maybe we've gotten lucky here and you really are dealing with this simple case!

cronjob that repeats every one minute:
Code:
ln /path/to/source/dir/* /path/to/destination/dir/ >/dev/null 2>&1
cronjob that repeats as needed for cleanup of files in source (this example deletes files over a day old):
Code:
find /path/to/source/dir -type f -mtime +1 -print | xargs rm -f >/dev/null 2>&1
 
Old 07-28-2006, 03:25 PM   #5
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
The normal thing to do is that when a mod does the "please do not post....." thing, stop responding.

Thread closed.
 
  


Closed Thread



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Non Continuous File Status (fragmentation)? carl0ski Mandriva 0 02-07-2005 08:34 AM
Installing file manager with root status giri2 Mandriva 4 07-23-2004 06:40 AM
file status pprajeev Linux - General 4 09-26-2003 06:59 AM
file status pprajeev Linux - Newbie 1 09-26-2003 06:30 AM
Error in Logrotate.status file tomdlam Linux - General 0 10-17-2002 08:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:48 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