bug-parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU Parallel Bug Reports Job slot number {%}


From: Ole Tange
Subject: Re: GNU Parallel Bug Reports Job slot number {%}
Date: Wed, 24 Sep 2014 17:22:36 +0200

On Tue, Sep 23, 2014 at 6:01 AM, Jamshid Afshar <address@hidden> wrote:
> Hi, I'm trying to use the job slot number "{%}" in order to run a
> command on a pool of servers.
:
> Running all the below commands at the same time seems to work as
> expected -- only three jobs run at a time, but "{%}" is always "1".
>
> I'd expect it to cycle 1-3.
>
> If there's a way of accomplish this with some simple scripting, please
> let me know, I'm not getting it. Thanks.

Change your script so you do not use sem but use parallel without --semaphore.

> sem --fg --jobs 3 --id my_id -u 'echo First started: $PARALLEL_SEQ,
> pretend to run on server {%} ; sleep 5; echo The first finished' &
> sem --fg --jobs 3 --id my_id -u 'echo Second started $PARALLEL_SEQ,
> pretend to run on server {%} ;  sleep 6; echo The second finished' &
> sem --fg --jobs 3 --id my_id -u 'echo Third started $PARALLEL_SEQ,
> pretend to run on server {%} ;  sleep 7; echo The third finished' &
> sem --fg --jobs 3 --id my_id -u 'echo Fourth started $PARALLEL_SEQ,
> pretend to run on server {%} ; sleep 8; echo The fourth finished' &
> sem --fg --jobs 3 --id my_id -u 'echo Fifth started $PARALLEL_SEQ,
> pretend to run on server {%} ; sleep 9; echo The fifth finished' &
> sem --fg --wait --id my_id

This could be written as:

    parallel -j3 -u 'echo Job {} started: {#}, pretend to run on
server {%};sleep {= $_+=4 =};echo Job {} finished' ::: {1..5}

/Ole



reply via email to

[Prev in Thread] Current Thread [Next in Thread]