Perl script to move files not in use


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl script to move files not in use
# 1  
Old 01-16-2009
Perl script to move files not in use

I need to write a script to move files only when they are not in use. I have a rudementry bash script for Linux but i need a perl script so it will work on Linux and hpux. Oracle writes files to a directory called /data and the files there are moved every 5 minutes to a new home. But i need to only move the files that oracle is not currently writing in the /data directory. Usually i have a script that partially works but i do not know where to start here (i am bad with perl). Any help would be appreciated.

Thank You,

Sean
# 2  
Old 01-16-2009
How are you going to see what files are in use? In linux you can do: lsof to see.. so I would start there..

In linux I would get the list by doing:
inuse=$(lsof | awk '$(NF) ~ /\/data/ {print $(NF);}');

Then comparing what was in data to it, and moving the files that weren't in use to a new location.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to move certain no. of files every second

Hi All, I am new to Linux/Scripting and need some assistance in coming up with a script that can move certain amount of files from one directory to other every seconds. Usercase: We have around 100k files in tmp directory on my server which needs to be moved to another folder to get... (3 Replies)
Discussion started by: Raj1184
3 Replies

2. Shell Programming and Scripting

Script move files by name

hi, I have a lot of files named xxxxx__AA.txt, xxxxx__BB.txt, xxxxx__CC.txt and I would like to move xxxxx__AA.txt in AA directory, xxxxx__BB.txt in BB etc. Could you help me do it in bash script? (5 Replies)
Discussion started by: corfuitl
5 Replies

3. Shell Programming and Scripting

help with a script to gzip/move files

Hi Please can you help me in writing a script to find files on a specific directory, and of extension "tap" but only of the month of september, gzip and move them to another directory. Your help will be appreciated. (4 Replies)
Discussion started by: fretagi
4 Replies

4. Shell Programming and Scripting

Need shell script to move files

Hi , I need a simple shell script to move the files from one directory to another directory after every 1 hour..!!! ?? (1 Reply)
Discussion started by: SARAL SAXENA
1 Replies

5. Shell Programming and Scripting

How to dynamically create user name in perl and move the files?

Hi, I have two problems in which i have stuck up. a) To move the files and copy back. b) To create user dynamically. Question 1: I have to move the files to some other directory and copy it when all the process is done. I have the code like this: $file = "/home/data/file1.txt";... (2 Replies)
Discussion started by: vanitham
2 Replies

6. UNIX for Dummies Questions & Answers

Script to move blank files

Anyone could give me an example of scrip to move blank files found into a dir? Thanks, Leandro Takeda (3 Replies)
Discussion started by: letakeda
3 Replies

7. Shell Programming and Scripting

Script to move trace files

Please debug this shell script for me.. Basically the idea is to run the script, based on the command to move some trace files to a separate directory and I am getting the error. Only the COMMAND that has rm {} works and I basically want to use it for the fourth one. Please try for the 2nd, 3rd and... (4 Replies)
Discussion started by: ST2000
4 Replies
Login or Register to Ask a Question