Need help for automated pickup of file based on a priority
Hi experts,
I am facing a problem right now.I have to automate the pickup of files based on a priority.The scenario is as below:
1) There will be files from Mon-Fri with Mon file being named as abc_def_01_YYYYMMDD and Tue file being abc_def_02_YYYYMMDD and so forth till Friday's file which would be abc_def_YYYYMMDD.
2) I have to set a priority such that if on any given day if i have more than one file, I have to send the earlier file first.For instance if on Thursday i have monday's file and wednesday's file I have to send the Monday's file first, then after a pre-defined delay send Wednesday's file-delay- and then send the thursday's file.
3) The trigger for the script is the file itself.Incoming file will trigger the script.
To start with, I have written the following code which stores the filenames in separate variables:
Code:
#!/sh/bin
cd /location
for i in `ls -lrt /location | awk '{print $9}'`
do
if [ "`echo $i | awk '{print $1}' | cut -d'_' -f3`" = "01" ]; then
first_file="$i"
elif [ "`echo $i | awk '{print $1}' | cut -d'_' -f3`" = "02" ]; then
second_file="$i"
elif [ "`echo $i | awk '{print $1}' | cut -d'_' -f3`" = "03" ]; then
third_file="$i"
elif [ "`echo $i | awk '{print $1}' | cut -d'_' -f3`" = "04" ]; then
fourth_file="$i"
elif [ "`echo $i | awk '{print $1}' | cut -d'_' -f3`" = "05" ]; then
fifth_file="$i"
else
echo "i am in the else loop" >> /dev/null
fi
done
Having done this i dont know how to set the priority so that at any given day if there is more than one file, the file of the earlier day of the week should be sent first.
Kindly help me on this.Thanks in advance
Last edited by vbe; 10-16-2013 at 09:33 AM..
Reason: badly placed icodes... replaced by code tags...
ls -tr /incoming/* | while read f
do
( whatever you do to process $f )
mv $f /archive
done
If you cannot trust modify time, you need to extract the date from the file name in a sortable order, prefix the file name with the key, sort and extract the file name from each output line.
Code:
ls incoming/* | sed 's/.*\(_20[0-9][0-9][[01][0-9][0-3][0-9].*\)/\1 &/' | sort | while read k f do
( whatever you do to process $f )
mv $f /archive
done
If you can name them something like constant_stuff+YYYYMMDDHHMMSS+variable_stuff, they sort right using shell glob '*'.
Last edited by DGPickett; 10-23-2013 at 05:46 PM..
Hi All,
Is there any way I can prioritize my VMs when there is resource crunch in host machine so that some VMs will be allocated more vcpu, more memory than other VMs in kvm/qemu hypervisor based virtual machines?
Lets say in my cloud environment my Ubuntu 16 compute hosts are running some... (0 Replies)
please help, I would like to merge 4 files, all of them same format.
The first col is the key for all files,followed by variable number of fields so I want to check if the key is present in the files according to priority and then also add a column saying it came from which file .
So the... (4 Replies)
Hi Gurus,
I am a newbie to shell scripting and I am facing a problem right now.I have to automate the copy of files based on a priority.The scenario is as below:
1) There will be files from Mon-Fri with Mon file being named as abc_def_01_YYYYMMDD and Tue file being abc_def_02_YYYYMMDD and so... (4 Replies)
Hi Gurus,
I need to develop a script which picks the files in a pre-defined order.
The files from monday-friday will be named as abc_01_20130923 as monday's file and abc_02_20130924 as tuesday's..so..so forth till friday's which will be named as abc_05_20130927.It repeats over for the... (3 Replies)
I've been looking online trying to find the correct value nice and priority can take in the limits.conf file. ON the man page it says;
Does this mean priority can be any negative number and any positive?
Then
Does this mean any number between -20 and 19 also what does the definition of nice... (13 Replies)
Hi,
I have two files to pick and excute these ones.
File1:DOLFIN.PRL_100.OIB.TLU.001.D20110510.T144948
File2:DOLFIN.PRM_100.OTU.001.D20100726.T050026
date '+%H:%M:%S'
SCRIPTS_PATH=/u/dolfin/bin
. ${SCRIPTS_PATH}/set_dolfin_env.sh
DATA_FILE_NAME=DATA_FILE
DATE_FORMAT=`date... (2 Replies)
Hi all,
which file has the low priority while linux booting?. I just want to run a script in background with low priority while linux boots up.(I need to include that script to be called from that file) as am a newbie to linux. Any help is appreciated.
Thanks,
SMNK (2 Replies)
Hi,
Can any body help me,How to pickup file from folder using shellscript.
FolderName:/test
FileinFolder: test.txt
MY req is:Shellscript pickup file from folder and pass file as parameter to java program..?
Thanks,
Rams (0 Replies)