shell - Queue using several processes to launch bash jobs -


i need run many (hundreds) commands in shell, want have maximum of 4 processes running (from queue) @ once. each process last several hours.

when process finishes want next command "popped" queue , executed.

i want able add more process after beginning, , great if remove jobs queue, or @ least empty queue.

i have seen solutions using makefile, work if have list of commands before beginning. tried using mkfifo sjobq, , others, never reach needs...

does have code solve problem?

edit: in response mark setchell

the solution tail -f , parallel perfect, when it, keep not launching last 4 commands until add more, , on, don't know why, , quite troublesome...

as redis, solution also, takes more time master of it.

thanks !

use gnu parallel make job queue this:

# clear out file containing job queue > jobqueue          # start gnu parallel processing jobs queue #   -k   means "keep" output in order #   -j 4 means run 4 jobs @ time tail -f jobqueue | parallel -k -j 4  # terminal, submit 40 jobs queue in {1..40}; echo "sleep 5;date +'%h:%m:%s job $i'"; done >> jobqueue 

another option use redis - see answer here run several jobs parallelly , efficiently


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -