File queue script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File queue script
# 1  
Old 06-08-2005
File queue script

Dear Gurus,
I have an application that sends me thousands of small files.
I need to write a script that sleeps for some time untile enough files have arrived then concatenate (n) files into 1 big file, then send that big file to a program to process it.

For example, if I have the following files
f1, f2, f3, f4, f5

assuming n=3
the script will do noting until f1, f2, f3 arrive, then:

It would do something like this:
cat f1 f2 f3 > bigfile and then executes another program to execute bigfile

then it would wait for the next 3 files to be available or a time period has elapsed (to cover for the case of only x < n files ever arriving) - In this example, it would wait some time after f5 arrives, then does something like this:
cat f4 f5 > bigfile and then executes another program to process bigfile

In short I need to write a script that deals with input files as a FIFO queue. I am sure some one some where must have written a similar one.

Could you point me to some source?

Thanks.

Last edited by GMMike; 06-08-2005 at 04:32 PM..
# 2  
Old 06-10-2005
MySQL

Here I give u a backbone to work on...Though I have not tried it... but should work with changes as per your need.

Code:
#!/usr/bin/ksh

#N is the number of files, you wish to wait for.
N=3

#T is time you wish to wait for in seconds.
T=10

#SPECIFIED_TIME time you assume all files have arrived.
SPECIFIED_TIME=2000

START_TIME=`date '+%Y%m%d%H%M%S'
FLAG=0

while 1
do
find $FILE_LOCATION -name $NAME* -exec ls -ltr {} \; > tmpfile
FILE_CNT='wc -l tmpfile | awk '{print $1}'`

if [ $FILE_CNT -ge $N -o $FLAG -eq 1 ]; then
  rm -f bigfile
  for i = 1 to $N
  do 
    file_nm=`head -1 tmpfile | awk '{ print $9 }'`
    sed -n '1d' tmpfile > tmpfile
    cat $file_nm >> bigfile
  done
  
  if [ $FLAG -eq 1 ]; then
    exit
  fi
  
fi

sleep $T

CUR_TIME=`date '+%Y%m%d%H%M%S'
diff=`expr $CUR_TIME - $START_TIME`
if [ $diff > $SPECIFIED_TIME ]; then
 FLAG=1
fi

done

# 3  
Old 10-23-2007
Files Processing for the repeted time periods

Hi,
I need a help from any of you guys.

Actually my scenario is same but little bit different.

Iam having 3 Processes Pr1,Pr2 and Pr3 . I would like to run every process in every 15 Min and i want to load the files.
i.e
first
15 Min : Pr1 Should trigger
after next 15 min : Pr2 Should run
then next 15 min : Pr3 Should run
then next 15 min : again Pr1 should run before running it should check the status of Pr1 of the first cycle whether it is completed or not.If it is completed then it should run the Pr1 Process else it should check wheter the Pr2 and Pr3 Process are running or not. Basically the free process has to kick off.

Basically i use to get files in every 15min , so i want to process it through the above mentioned 3 Processses.

kindly help me on the same.


Script:


wait $var_band1

if [ $? -eq 0 ]

then

echo " Execute Band1 " &

var_band1=$!

echo "var_band1 : $var_band1"

sleep 3

echo "Waiting for the Next Hr Files "

else

echo "Still the Band1 Process is Running"

fi



wait $var_band2

if [ $? -eq 0 ]

then

echo " Execute Band2 " &

var_band2=$!

echo "var_band2 : $var_band2"

sleep 3

echo "Waiting for the Next Hr Files "

else

echo "Still the Band2 Process is Running"

fi



wait $var_band3

if [ $? -eq 0 ]

then

echo " Execute Band3 " &

var_band3=$!

echo "var_band3 : $var_band3"

sleep 3

echo "Waiting for the Next Hr Files "

else

echo "Still the Band3 Process is Running"

fi

Last edited by krk_555; 10-23-2007 at 08:27 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

MQ Queue Manager SSL Checking Script

Hello everyone, Newbie to the forum. I have a requirement for a script to check Queue Manager SSL certificates - However I have no previous scripting skills what so ever. I need a script which from high level point of view does the following: #For each Queue Manager on the server go to... (1 Reply)
Discussion started by: MQAdmin
1 Replies

2. Shell Programming and Scripting

Shell Script for Websphere MQ Queue Manager start/stop

Hello All, I am completely new to shell scripting. I had to write a script that starts and stop the queue manager in Websphere MQ. We are on Linux 64-bit patform. The script should stop the queue manager and all the processes related to websphere MQ. It should be a clean stop. Once the queue... (3 Replies)
Discussion started by: pady1224
3 Replies

3. Shell Programming and Scripting

How to write Perl Script to Get MQ Queue Depth?

Hi , I got the following script from internet to display queue depth using Perl Script. However, when I execute it , im getting following error. Can anyone shed light on what is going wrong? #!/usr/bin/perl ## 07/23/01 ## Depth Inquiry sample program. ## Arguments: ## Connects to... (11 Replies)
Discussion started by: srkmish
11 Replies

4. AIX

Help with clear printer queue script in AIX 5.3

Good day UNIX forum, could you help me with my clear printer queue script, i have problems with the consistency of this function, sometimes it works sometimes it doesn't. Thanks in advance } preRemovePrintQ(){ clear; echo; echo... (1 Reply)
Discussion started by: beware187
1 Replies

5. Shell Programming and Scripting

Detect if script starts from queue

Dear community, what I'm try to do is deny users to run a script without parameters from command bash, but the same script should run without parameters only from crontab. Example runs by crontab:*/5 * * * * /tmp/script.sh Here the normal execution starts every 5 minutes Example #1 runs by... (16 Replies)
Discussion started by: Lord Spectre
16 Replies

6. AIX

AIX Bunch of printers queue creation script - HELP

I'd seek for help on how to create a bunch of printers in AIX 6.x or equal or above in one go – say like I have 35 printers to create in 4 different AIX Nodes every month – I currently create it manually like below:- How can I automatic this creation on all the 4-5 Nodes – not actually automatic... (3 Replies)
Discussion started by: shiv2001in
3 Replies

7. AIX

AIX 6.1 Error - "A file, file system or message queue is no longer available."

Getting a strange error with a log file below. This is just a normal text log file that is written to by an application on the server. The applicaiton is down, however, I cannot read, remove or touch this file. The file shows on an ls listing but not an ls -al listing. The file system is JFS2... (0 Replies)
Discussion started by: troym72
0 Replies

8. Shell Programming and Scripting

Need Help Writing Script To Email When Fax Queue Goes Down

I need a script that would email me when the fax queue goes down. How would I go about doing this? Our fax queue drops a few times a week and if I don't catch it fairly quickly it gets backed up really fast which makes the users a little unhappy... I am new to Unix-AIX. We are running... (6 Replies)
Discussion started by: ITAdmin08
6 Replies

9. Shell Programming and Scripting

shell script needed for mail queue notification

Hi shell experts, I would like to have a shell script running in a redhat server for monitoring the mailqueue status. I have already installed the qmHandle and I am using it to get a status of the mail queue in daily basis. I am executing the qmhandle in the cron. Now I am planning to execute... (10 Replies)
Discussion started by: Nightman
10 Replies

10. Programming

Queue

:confused: I have some problem with the technology Queue in Unix Can someone explain me the way queue is made and how it excute ,how it run Thanks in advance (1 Reply)
Discussion started by: iwbasts
1 Replies
Login or Register to Ask a Question