How can I run GNU parallel in record per job, with 1 process per core

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.



I've come up with this



echo 1..10 | xargs -n1 | parallel -m 'echo ""';


which prints



7 8 9
10
4 5 6
1 2 3


but what I really want to see is (note order doesn't actually matter).



1
2
3
4
5
6
7
8
9
10


and those would be processed in parallel 4 at a time (or whatever number of cpus/cores, I have, e.g. --jobs 4). For a total of 10 separate executions.



I tried this



echo 1..10 | xargs -n1 | parallel --semaphore --block 3 -m 'echo -n " ";


but it only ever seems to print once. bonus points if your solution doesn't need xargs which seems like a hack around the idea that the default record separator is a newline, but I haven't been able to get a space to work like I want either.



10 is a reasonably small number, but lets say it's much larger, 1000



echo 1..1000 | xargs -n1 | parallel -j1000


prints



parallel: Warning: Only enough file handles to run 60 jobs in parallel.
parallel: Warning: Running 'parallel -j0 -N 60 --pipe parallel -j0' or
parallel: Warning: raising 'ulimit -n' or 'nofile' in /etc/security/limits.conf
parallel: Warning: or /proc/sys/fs/file-max may help.


I don't actually want 1000 processes, I want 4 processes at a time, each process should process 1 record, thus by the time I'm done it will have executed 1000 times.







share|improve this question






















  • I'm getting the expected result with echo 1..10 | xargs -n1 | parallel -m 'echo ""';. The output is 1 2 3 4 5n 6 7 8 9 10 (n - linebreak in real). Works fine (GNU parallel 20141022)
    – RomanPerekhrest
    Oct 27 '17 at 20:24











  • @Roman that newline says it only executed twice, I should actually have 10 separate executions
    – xenoterracide
    Oct 27 '17 at 20:26










  • 10 separate executions is 10 jobs, as you know
    – RomanPerekhrest
    Oct 27 '17 at 20:27










  • @RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
    – xenoterracide
    Oct 27 '17 at 20:29















up vote
2
down vote

favorite












What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.



I've come up with this



echo 1..10 | xargs -n1 | parallel -m 'echo ""';


which prints



7 8 9
10
4 5 6
1 2 3


but what I really want to see is (note order doesn't actually matter).



1
2
3
4
5
6
7
8
9
10


and those would be processed in parallel 4 at a time (or whatever number of cpus/cores, I have, e.g. --jobs 4). For a total of 10 separate executions.



I tried this



echo 1..10 | xargs -n1 | parallel --semaphore --block 3 -m 'echo -n " ";


but it only ever seems to print once. bonus points if your solution doesn't need xargs which seems like a hack around the idea that the default record separator is a newline, but I haven't been able to get a space to work like I want either.



10 is a reasonably small number, but lets say it's much larger, 1000



echo 1..1000 | xargs -n1 | parallel -j1000


prints



parallel: Warning: Only enough file handles to run 60 jobs in parallel.
parallel: Warning: Running 'parallel -j0 -N 60 --pipe parallel -j0' or
parallel: Warning: raising 'ulimit -n' or 'nofile' in /etc/security/limits.conf
parallel: Warning: or /proc/sys/fs/file-max may help.


I don't actually want 1000 processes, I want 4 processes at a time, each process should process 1 record, thus by the time I'm done it will have executed 1000 times.







share|improve this question






















  • I'm getting the expected result with echo 1..10 | xargs -n1 | parallel -m 'echo ""';. The output is 1 2 3 4 5n 6 7 8 9 10 (n - linebreak in real). Works fine (GNU parallel 20141022)
    – RomanPerekhrest
    Oct 27 '17 at 20:24











  • @Roman that newline says it only executed twice, I should actually have 10 separate executions
    – xenoterracide
    Oct 27 '17 at 20:26










  • 10 separate executions is 10 jobs, as you know
    – RomanPerekhrest
    Oct 27 '17 at 20:27










  • @RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
    – xenoterracide
    Oct 27 '17 at 20:29













up vote
2
down vote

favorite









up vote
2
down vote

favorite











What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.



I've come up with this



echo 1..10 | xargs -n1 | parallel -m 'echo ""';


which prints



7 8 9
10
4 5 6
1 2 3


but what I really want to see is (note order doesn't actually matter).



1
2
3
4
5
6
7
8
9
10


and those would be processed in parallel 4 at a time (or whatever number of cpus/cores, I have, e.g. --jobs 4). For a total of 10 separate executions.



I tried this



echo 1..10 | xargs -n1 | parallel --semaphore --block 3 -m 'echo -n " ";


but it only ever seems to print once. bonus points if your solution doesn't need xargs which seems like a hack around the idea that the default record separator is a newline, but I haven't been able to get a space to work like I want either.



10 is a reasonably small number, but lets say it's much larger, 1000



echo 1..1000 | xargs -n1 | parallel -j1000


prints



parallel: Warning: Only enough file handles to run 60 jobs in parallel.
parallel: Warning: Running 'parallel -j0 -N 60 --pipe parallel -j0' or
parallel: Warning: raising 'ulimit -n' or 'nofile' in /etc/security/limits.conf
parallel: Warning: or /proc/sys/fs/file-max may help.


I don't actually want 1000 processes, I want 4 processes at a time, each process should process 1 record, thus by the time I'm done it will have executed 1000 times.







share|improve this question














What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.



I've come up with this



echo 1..10 | xargs -n1 | parallel -m 'echo ""';


which prints



7 8 9
10
4 5 6
1 2 3


but what I really want to see is (note order doesn't actually matter).



1
2
3
4
5
6
7
8
9
10


and those would be processed in parallel 4 at a time (or whatever number of cpus/cores, I have, e.g. --jobs 4). For a total of 10 separate executions.



I tried this



echo 1..10 | xargs -n1 | parallel --semaphore --block 3 -m 'echo -n " ";


but it only ever seems to print once. bonus points if your solution doesn't need xargs which seems like a hack around the idea that the default record separator is a newline, but I haven't been able to get a space to work like I want either.



10 is a reasonably small number, but lets say it's much larger, 1000



echo 1..1000 | xargs -n1 | parallel -j1000


prints



parallel: Warning: Only enough file handles to run 60 jobs in parallel.
parallel: Warning: Running 'parallel -j0 -N 60 --pipe parallel -j0' or
parallel: Warning: raising 'ulimit -n' or 'nofile' in /etc/security/limits.conf
parallel: Warning: or /proc/sys/fs/file-max may help.


I don't actually want 1000 processes, I want 4 processes at a time, each process should process 1 record, thus by the time I'm done it will have executed 1000 times.









share|improve this question













share|improve this question




share|improve this question








edited Oct 27 '17 at 20:41

























asked Oct 27 '17 at 20:20









xenoterracide

24.6k51156218




24.6k51156218











  • I'm getting the expected result with echo 1..10 | xargs -n1 | parallel -m 'echo ""';. The output is 1 2 3 4 5n 6 7 8 9 10 (n - linebreak in real). Works fine (GNU parallel 20141022)
    – RomanPerekhrest
    Oct 27 '17 at 20:24











  • @Roman that newline says it only executed twice, I should actually have 10 separate executions
    – xenoterracide
    Oct 27 '17 at 20:26










  • 10 separate executions is 10 jobs, as you know
    – RomanPerekhrest
    Oct 27 '17 at 20:27










  • @RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
    – xenoterracide
    Oct 27 '17 at 20:29

















  • I'm getting the expected result with echo 1..10 | xargs -n1 | parallel -m 'echo ""';. The output is 1 2 3 4 5n 6 7 8 9 10 (n - linebreak in real). Works fine (GNU parallel 20141022)
    – RomanPerekhrest
    Oct 27 '17 at 20:24











  • @Roman that newline says it only executed twice, I should actually have 10 separate executions
    – xenoterracide
    Oct 27 '17 at 20:26










  • 10 separate executions is 10 jobs, as you know
    – RomanPerekhrest
    Oct 27 '17 at 20:27










  • @RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
    – xenoterracide
    Oct 27 '17 at 20:29
















I'm getting the expected result with echo 1..10 | xargs -n1 | parallel -m 'echo ""';. The output is 1 2 3 4 5n 6 7 8 9 10 (n - linebreak in real). Works fine (GNU parallel 20141022)
– RomanPerekhrest
Oct 27 '17 at 20:24





I'm getting the expected result with echo 1..10 | xargs -n1 | parallel -m 'echo ""';. The output is 1 2 3 4 5n 6 7 8 9 10 (n - linebreak in real). Works fine (GNU parallel 20141022)
– RomanPerekhrest
Oct 27 '17 at 20:24













@Roman that newline says it only executed twice, I should actually have 10 separate executions
– xenoterracide
Oct 27 '17 at 20:26




@Roman that newline says it only executed twice, I should actually have 10 separate executions
– xenoterracide
Oct 27 '17 at 20:26












10 separate executions is 10 jobs, as you know
– RomanPerekhrest
Oct 27 '17 at 20:27




10 separate executions is 10 jobs, as you know
– RomanPerekhrest
Oct 27 '17 at 20:27












@RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
– xenoterracide
Oct 27 '17 at 20:29





@RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
– xenoterracide
Oct 27 '17 at 20:29











2 Answers
2






active

oldest

votes

















up vote
4
down vote



accepted











I want 4 processes at a time, each process should process 1 record




parallel -j4 -k --no-notice 'echo ""' ::: 1..10


  • -j4 - number of jobslots. Run up to 4 jobs in parallel


  • -k - keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes


  • ::: - arguments



The output:



1
2
3
4
5
6
7
8
9
10





share|improve this answer






















  • Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong: parallel "echo ''" ::: '$'
    – Ole Tange
    Oct 29 '17 at 23:04


















up vote
1
down vote













seq 10 | parallel -j4 echo 


Or if you have 4 cores:



seq 10 | parallel echo





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f400958%2fhow-can-i-run-gnu-parallel-in-record-per-job-with-1-process-per-core%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote



    accepted











    I want 4 processes at a time, each process should process 1 record




    parallel -j4 -k --no-notice 'echo ""' ::: 1..10


    • -j4 - number of jobslots. Run up to 4 jobs in parallel


    • -k - keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes


    • ::: - arguments



    The output:



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10





    share|improve this answer






















    • Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong: parallel "echo ''" ::: '$'
      – Ole Tange
      Oct 29 '17 at 23:04















    up vote
    4
    down vote



    accepted











    I want 4 processes at a time, each process should process 1 record




    parallel -j4 -k --no-notice 'echo ""' ::: 1..10


    • -j4 - number of jobslots. Run up to 4 jobs in parallel


    • -k - keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes


    • ::: - arguments



    The output:



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10





    share|improve this answer






















    • Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong: parallel "echo ''" ::: '$'
      – Ole Tange
      Oct 29 '17 at 23:04













    up vote
    4
    down vote



    accepted







    up vote
    4
    down vote



    accepted







    I want 4 processes at a time, each process should process 1 record




    parallel -j4 -k --no-notice 'echo ""' ::: 1..10


    • -j4 - number of jobslots. Run up to 4 jobs in parallel


    • -k - keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes


    • ::: - arguments



    The output:



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10





    share|improve this answer















    I want 4 processes at a time, each process should process 1 record




    parallel -j4 -k --no-notice 'echo ""' ::: 1..10


    • -j4 - number of jobslots. Run up to 4 jobs in parallel


    • -k - keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes


    • ::: - arguments



    The output:



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 28 '17 at 8:54

























    answered Oct 27 '17 at 21:15









    RomanPerekhrest

    22.5k12145




    22.5k12145











    • Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong: parallel "echo ''" ::: '$'
      – Ole Tange
      Oct 29 '17 at 23:04

















    • Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong: parallel "echo ''" ::: '$'
      – Ole Tange
      Oct 29 '17 at 23:04
















    Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong: parallel "echo ''" ::: '$'
    – Ole Tange
    Oct 29 '17 at 23:04





    Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong: parallel "echo ''" ::: '$'
    – Ole Tange
    Oct 29 '17 at 23:04













    up vote
    1
    down vote













    seq 10 | parallel -j4 echo 


    Or if you have 4 cores:



    seq 10 | parallel echo





    share|improve this answer
























      up vote
      1
      down vote













      seq 10 | parallel -j4 echo 


      Or if you have 4 cores:



      seq 10 | parallel echo





      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        seq 10 | parallel -j4 echo 


        Or if you have 4 cores:



        seq 10 | parallel echo





        share|improve this answer












        seq 10 | parallel -j4 echo 


        Or if you have 4 cores:



        seq 10 | parallel echo






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 28 '17 at 18:57









        Ole Tange

        11.4k1344102




        11.4k1344102



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f400958%2fhow-can-i-run-gnu-parallel-in-record-per-job-with-1-process-per-core%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay