Balance the load of files across queues using shell script

Hi,
I need to balance the load to be processed by the system using shell script.
The scenario is like below:

Suppose there are some files in a directory:

-rw-rw-r--    1 usr     usrgrp     456432306 Oct 23 07:53 abc_queue_q1
-rw-rw-r--    1 usr     usrgrp     4123934 Oct 23 07:53 def_queue_q1
-rw-rw-r--    1 usr     usrgrp     14     Oct 25 09:01 ghi_queue_q1
-rw-rw-r--    1 usr     usrgrp     10     Oct 25 09:01 jkl_queue_q1
-rw-rw-r--    1 usr     usrgrp     10     Oct 25 09:01 mno_queue_q1
-rw-rw-r--    1 usr     usrgrp     50765487     Oct 25 09:01 mno_queue_q1
-rw-rw-r--    1 usr     usrgrp     98765412     Oct 25 09:01 mno_queue_q1

and there are 4 queues available across which we can distribute the load
queue_q1,queue_q2,queue_q3,queue_q4

but the files were submitted haphazardly...Now we need to manage the load across all 4 queues. So that the equal load is shared among the queues.

So in our case the output should be like:

-rw-rw-r--    1 usr     usrgrp     456432306 Oct 23 07:53 abc_queue_q1
-rw-rw-r--    1 usr     usrgrp     4123934 Oct 23 07:53 def_queue_q2
-rw-rw-r--    1 usr     usrgrp     14     Oct 25 09:01 ghi_queue_q2
-rw-rw-r--    1 usr     usrgrp     10     Oct 25 09:01 jkl_queue_q2
-rw-rw-r--    1 usr     usrgrp     10     Oct 25 09:01 mno_queue_q2
-rw-rw-r--    1 usr     usrgrp     50765487     Oct 25 09:01 mno_queue_q3
-rw-rw-r--    1 usr     usrgrp     98765412     Oct 25 09:01 mno_queue_q4

there could be n number of conditions to balance the load..conditions could be:
there are thousands of files on queue_q1. suppose the total size of all the file on queue_q1 is 1000 MB..then 250 MB will be distributed across all 4 queues...

If there is 1 big file which is on queue_q1 and some small files ... then you need to balance the load.,..Remember you will not break any file...We just try to manage the load that is possible.

Your consistent unwillingness to use CODE tags and to rely on moderators to clean up your posts is troubling.

The fact that you never show any code that you're working on and seem only to want us to write code for you is troubling.

The fact that this posting sounds more like a homework assignment than something you're working on on your own is troubling.

In the future, post homework assignments in the Homework & Coursework Questions forum, show us that you are making an effort to solve problems on your own, and PLEASE use CODE tags as required by forum rules.

This thread is closed.

1 Like