Linux command that spawns multiple processes












3















I am looking for a linux command (like ls, time or anything similar) that spawns multiple processes. Anything which is to be run from a command line and not a shell script.



The reason is I want to see parent-child relationship on the htop and with different Process IDs.



Thanks










share|improve this question







New contributor




talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 3





    It might be easier to write a program than to use an existing command. After all, commands exist to do something, and you might not want that something to be done. You could easily write a program that spawns processes that do something like compute the first N primes, taking up processor cycles but having no other effect on your system.

    – jamesqf
    yesterday











  • Would dig do?

    – kasperd
    15 hours ago
















3















I am looking for a linux command (like ls, time or anything similar) that spawns multiple processes. Anything which is to be run from a command line and not a shell script.



The reason is I want to see parent-child relationship on the htop and with different Process IDs.



Thanks










share|improve this question







New contributor




talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 3





    It might be easier to write a program than to use an existing command. After all, commands exist to do something, and you might not want that something to be done. You could easily write a program that spawns processes that do something like compute the first N primes, taking up processor cycles but having no other effect on your system.

    – jamesqf
    yesterday











  • Would dig do?

    – kasperd
    15 hours ago














3












3








3


1






I am looking for a linux command (like ls, time or anything similar) that spawns multiple processes. Anything which is to be run from a command line and not a shell script.



The reason is I want to see parent-child relationship on the htop and with different Process IDs.



Thanks










share|improve this question







New contributor




talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I am looking for a linux command (like ls, time or anything similar) that spawns multiple processes. Anything which is to be run from a command line and not a shell script.



The reason is I want to see parent-child relationship on the htop and with different Process IDs.



Thanks







command-line process






share|improve this question







New contributor




talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









talekeDskobeDatalekeDskobeDa

191




191




New contributor




talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






talekeDskobeDa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 3





    It might be easier to write a program than to use an existing command. After all, commands exist to do something, and you might not want that something to be done. You could easily write a program that spawns processes that do something like compute the first N primes, taking up processor cycles but having no other effect on your system.

    – jamesqf
    yesterday











  • Would dig do?

    – kasperd
    15 hours ago














  • 3





    It might be easier to write a program than to use an existing command. After all, commands exist to do something, and you might not want that something to be done. You could easily write a program that spawns processes that do something like compute the first N primes, taking up processor cycles but having no other effect on your system.

    – jamesqf
    yesterday











  • Would dig do?

    – kasperd
    15 hours ago








3




3





It might be easier to write a program than to use an existing command. After all, commands exist to do something, and you might not want that something to be done. You could easily write a program that spawns processes that do something like compute the first N primes, taking up processor cycles but having no other effect on your system.

– jamesqf
yesterday





It might be easier to write a program than to use an existing command. After all, commands exist to do something, and you might not want that something to be done. You could easily write a program that spawns processes that do something like compute the first N primes, taking up processor cycles but having no other effect on your system.

– jamesqf
yesterday













Would dig do?

– kasperd
15 hours ago





Would dig do?

– kasperd
15 hours ago










2 Answers
2






active

oldest

votes


















14














The & command separator will do this for you. Use it carefully and wisely, but here is a simple way to see process relationships:



$ sleep 5 & pstree -p $$
[1] 13369
bash(13337)─┬─pstree(13370)
└─sleep(13369)


The [1] 13369 shows that sleep (which has PID 13369), has been put into the background as Job #1. $$ returns to the shell the PID of itself, so we feed that into pstree to show the process tree with a root of our shell's PID, to show all child processes.






share|improve this answer































    8














    If you don't want to have any shells in the mix, you can simply use one of the "wrapper" programs that spawn another program to do something with it:




    • /bin/time sleep 60


    • watch sleep 1 (this one will keep respawning sleep)






    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',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });






      talekeDskobeDa is a new contributor. Be nice, and check out our Code of Conduct.










      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498162%2flinux-command-that-spawns-multiple-processes%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      14














      The & command separator will do this for you. Use it carefully and wisely, but here is a simple way to see process relationships:



      $ sleep 5 & pstree -p $$
      [1] 13369
      bash(13337)─┬─pstree(13370)
      └─sleep(13369)


      The [1] 13369 shows that sleep (which has PID 13369), has been put into the background as Job #1. $$ returns to the shell the PID of itself, so we feed that into pstree to show the process tree with a root of our shell's PID, to show all child processes.






      share|improve this answer




























        14














        The & command separator will do this for you. Use it carefully and wisely, but here is a simple way to see process relationships:



        $ sleep 5 & pstree -p $$
        [1] 13369
        bash(13337)─┬─pstree(13370)
        └─sleep(13369)


        The [1] 13369 shows that sleep (which has PID 13369), has been put into the background as Job #1. $$ returns to the shell the PID of itself, so we feed that into pstree to show the process tree with a root of our shell's PID, to show all child processes.






        share|improve this answer


























          14












          14








          14







          The & command separator will do this for you. Use it carefully and wisely, but here is a simple way to see process relationships:



          $ sleep 5 & pstree -p $$
          [1] 13369
          bash(13337)─┬─pstree(13370)
          └─sleep(13369)


          The [1] 13369 shows that sleep (which has PID 13369), has been put into the background as Job #1. $$ returns to the shell the PID of itself, so we feed that into pstree to show the process tree with a root of our shell's PID, to show all child processes.






          share|improve this answer













          The & command separator will do this for you. Use it carefully and wisely, but here is a simple way to see process relationships:



          $ sleep 5 & pstree -p $$
          [1] 13369
          bash(13337)─┬─pstree(13370)
          └─sleep(13369)


          The [1] 13369 shows that sleep (which has PID 13369), has been put into the background as Job #1. $$ returns to the shell the PID of itself, so we feed that into pstree to show the process tree with a root of our shell's PID, to show all child processes.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          DopeGhotiDopeGhoti

          45.1k55988




          45.1k55988

























              8














              If you don't want to have any shells in the mix, you can simply use one of the "wrapper" programs that spawn another program to do something with it:




              • /bin/time sleep 60


              • watch sleep 1 (this one will keep respawning sleep)






              share|improve this answer




























                8














                If you don't want to have any shells in the mix, you can simply use one of the "wrapper" programs that spawn another program to do something with it:




                • /bin/time sleep 60


                • watch sleep 1 (this one will keep respawning sleep)






                share|improve this answer


























                  8












                  8








                  8







                  If you don't want to have any shells in the mix, you can simply use one of the "wrapper" programs that spawn another program to do something with it:




                  • /bin/time sleep 60


                  • watch sleep 1 (this one will keep respawning sleep)






                  share|improve this answer













                  If you don't want to have any shells in the mix, you can simply use one of the "wrapper" programs that spawn another program to do something with it:




                  • /bin/time sleep 60


                  • watch sleep 1 (this one will keep respawning sleep)







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  TooTeaTooTea

                  659110




                  659110






















                      talekeDskobeDa is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      talekeDskobeDa is a new contributor. Be nice, and check out our Code of Conduct.













                      talekeDskobeDa is a new contributor. Be nice, and check out our Code of Conduct.












                      talekeDskobeDa is a new contributor. Be nice, and check out our Code of Conduct.
















                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498162%2flinux-command-that-spawns-multiple-processes%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      Origin of the phrase “under your belt”?