Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: wait for the next process to finish



On Monday December 12 2011, Wayne Davison wrote:
> On Mon, Dec 12, 2011 at 7:46 AM, Anthony R Fletcher <arif@xxxxxxxxxxxx>wrote:
> 
> > How can I wait for just the next job to finish?

This is probably not exactly what you want and it isn't pretty either. But you could use `make' for this and use the -j flag for telling it to process stuff in parallel:


#---------------------------

make -j 4 -f =( cat <<EOF
default: task1 task2 task3 task4 task_finally

task1:
        @echo task1
        sleep 2
        @echo task1 finished

task2:
        @echo task2
        sleep 7
        @echo task2 finished

task3:
        @echo task3
        sleep 4
        @echo task3 finished

task4:
        @echo task4
        sleep 10
        @echo task4 finished

task_finally:
        @echo finally
EOF)

#---------------------------

However it is not really customizable and I think it is not really meant to be used that way. If this solution does not already make you shudder, you might also be able to construct something likewise using xargs and the --max-procs switch.

Martin



Messages sorted by: Reverse Date, Date, Thread, Author