![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
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). |
|
|||
|
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. |
|
|||
|
much smarter indeed
shame on me ![]() |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| shell script based on time |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
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 |