The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Nov 2009
Posts: 1
Thumbs up Moving the files based on count and time.

Hi,

I have a requirement ,let us say 1000 files needs to be transferred in an hour from one path to another path and if the files (1000 files) are transferred within an hour ( say 40 mins), then the process should remain idle for the remaining time ( 20 mins).
  #2 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Oct 2009
Posts: 8
Something like :



Code:
while [ `find $path1 -type file` -gt 0 ]
do
  beforeS=$(date +"%S")
  beforeM=$(date +"%M")
  beforeH=$(date +"%H")
  before=`expr $beforeS + beforeM * 60 + beforeH * 3600`
  find $path1 -type file | head -1000 | while read file
  do
     mv $file $path2
  done
  afterS=$(date +"%S")
  afterM=$(date +"%M")
  afterH=$(date +"%H")
  after=`expr $afterS + afterM * 60 + afterH * 3600`
  diff=$(($after-$before))
  remaining=`expr 3600 - $diff` #remaining in seconds
  [ $remaining -gt 0 ] && sleep $remaining
done

not tested though, and also wouldn't work if say the script is launched around midnight.. need to add the days, month and years in the calculation.
good luck.
  #3 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,258
Or:

Code:
sleep 3600&
perform-copy-operations
wait

  #4 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Oct 2009
Posts: 8
Quote:
Originally Posted by Scrutinizer View Post
Or:

Code:
sleep 3600&
perform-copy-operations
wait
much smarter indeed
shame on me
Sponsored Links
Reply

Bookmarks

Tags
shell script based on time

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This 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
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Moving files which are generating time to time Renjesh Shell Programming and Scripting 4 02-18-2009 06:41 PM
Finding files older than the current date and time and renaming and moving ragavhere Shell Programming and Scripting 7 11-21-2008 05:25 AM
Count of files based on date? sbasetty Shell Programming and Scripting 6 01-11-2007 03:02 PM
Find files based on time budrito UNIX for Advanced & Expert Users 4 10-08-2004 06:18 AM
Moving files based on creation date dgoyea UNIX for Dummies Questions & Answers 1 06-28-2001 06:43 PM



All times are GMT -4. The time now is 12:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0