Script to move certain number of files every 10 minutes.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script to move certain number of files every 10 minutes.
# 1  
Old 02-26-2007
Power Script to move certain number of files every 10 minutes.

Hi,

I need to move a certain number of files every 10 minutes from one folder to another. I have written the script below, however its not working, please advise.

#! /bin/ksh
start()
{

mv /test1/$(head -1000 /movetst) /test2/
sleep 600
}

stop()
{
exit
}

ls ti* > /movetest
count = cat /movetst | wc -l
if [ $count -eq 0 ]
then
start
else
stop
fi

Thanks&Regards,
Amit
# 2  
Old 02-26-2007
Something like this!

Code:
#! /bin/zsh

while :
do
  ls -1 somefile* | while read file
  do
    mv ./$file /anotherdir/$file
  done
  sleep 600
done

exit 0

 
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

Move all .log except those generated in the last 5 minutes

RHEL 5.8 In the directory /u03/pkms/app_logs I have several hundreds of log files as shown below. $ pwd /u03/pkms/app_logs $ ls -alrt *.log | tail -50 -rw-r----- 1 oracle dba 9439232 May 4 13:57 mvtpcem_1_722892404_94157.log -rw-r----- 1 oracle dba 9227264 May 4 13:57... (8 Replies)
Discussion started by: kraljic
8 Replies

3. Shell Programming and Scripting

Script to grep for a string in log files generated in last 15 minutes.

Dear Guru's I've a requirment to grep for a string in series of log files that are getting generated almost every minute. I'm looking to schedule a script every 15 mountes,in order to check if the error string has been generated in any of the log files generated in last 15 minutes. Please... (3 Replies)
Discussion started by: rajivatnova
3 Replies

4. 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

5. Shell Programming and Scripting

Help with command to Move files by X number to seperate directories

Hello, I need help finding a script that will allow me to move files from one directory to another directory 10k files at a time. I have a directory that has 100 K files in it. I need to have those 100k files broken apart to separate directories each with 10k files in them. Here is the... (8 Replies)
Discussion started by: Geo_Bean
8 Replies

6. Ubuntu

How can I move a file to a webserver every 5 minutes?

I'm using Ubuntu and I have a text file I want to FTP to a web server every 5 minutes. I want to overwrite the existing file every time so I don't have tons of the same file. (10 Replies)
Discussion started by: Bradj47
10 Replies

7. Shell Programming and Scripting

C Shell Script to convert a number into minutes

Could anyone tell me how to write a C shell script according to the following requirement. Write a C shell script convertmin which will read in a number, thought of as representing minutes, and print out the number of hours/minutes it represents so: Note: you are required to check exception... (1 Reply)
Discussion started by: Ringo
1 Replies
Login or Register to Ask a Question