Simple queuing system?

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












8















Given a commodity PC, we would like to use it to execute some tasks in the background round the clock.



Basically, we would like to have commands like:



add-task *insert command here*
list-tasks
remove-task(s)


The added tasks should simply be put in a queue and executed one after another in the background (keeping running after logout of the shell).



Is there any simple script/program that does this?










share|improve this question




























    8















    Given a commodity PC, we would like to use it to execute some tasks in the background round the clock.



    Basically, we would like to have commands like:



    add-task *insert command here*
    list-tasks
    remove-task(s)


    The added tasks should simply be put in a queue and executed one after another in the background (keeping running after logout of the shell).



    Is there any simple script/program that does this?










    share|improve this question


























      8












      8








      8


      3






      Given a commodity PC, we would like to use it to execute some tasks in the background round the clock.



      Basically, we would like to have commands like:



      add-task *insert command here*
      list-tasks
      remove-task(s)


      The added tasks should simply be put in a queue and executed one after another in the background (keeping running after logout of the shell).



      Is there any simple script/program that does this?










      share|improve this question
















      Given a commodity PC, we would like to use it to execute some tasks in the background round the clock.



      Basically, we would like to have commands like:



      add-task *insert command here*
      list-tasks
      remove-task(s)


      The added tasks should simply be put in a queue and executed one after another in the background (keeping running after logout of the shell).



      Is there any simple script/program that does this?







      process process-management scheduling






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 26 '11 at 22:31









      Gilles

      545k12811071622




      545k12811071622










      asked Aug 26 '11 at 7:06









      dagneliesdagnelies

      16027




      16027




















          4 Answers
          4






          active

          oldest

          votes


















          7














          There's a standard batch command that does more or less what you're after. More precisely, batch executes the jobs when the system load is not too high, one at a time (so it doesn't do any parallelization). The batch command is part of the at package.



          echo 'command1 --foo=bar' | batch 
          echo 'command2 "$(wibble)"' | batch
          at -q b -l # on many OSes, a slightly shorter synonym is: atq -q b
          at -q b -r 1234 # Unschedule a pending task (atq gives the task ID)





          share|improve this answer























          • It's wrong to say that the batch command "doesn't do any parallelization". There's usually a default 60sec delay between starting one job and starting the next; however, there's nothing to make the next job wait for the first to finish -- atd will happily kick off jobs from the batch queue as soon as the value set by the -b option has elapsed (see atd man page).

            – rsaw
            Apr 26 '16 at 21:35


















          3














          There are lots of queuing systems, but the are frequently very specialized.



          You might look into the at scheduler. It's like cron in some ways but it is setup more like a queue for one time jobs than for repeat jobs. It can "schedule" things on criteria other than time, such as system load or sequence of jobs.



          Your favorite distro will almost certainly have packages for it.






          share|improve this answer






























            2














            Another solution is to use lpd, and create a custom "print driver" that runs your jobs. A friend helped me work this out when I had a similar request. Make a script like this, and put it in /tmp/batch.sh:



            #!/bin/bash

            TMPFILE=$(mktemp /tmp/XXXX)
            exec <"$6"
            cat - > $TMPFILE
            chmod a+x $TMPFILE
            $TMPFILE
            rm -f $TMPFILE


            Then run:



            lpadmin -p batch1 -E -P /tmp/batch.sh


            That starts a queue, and you can create more by using other names instead of batch1. Add a job with:



            lp -d batch1 /path/to/jobscript


            Manage jobs with lpq, lprm, and lpstat. If you want more flexibility with passing arguments to your jobs, you can make the batch.sh script fancier.



            (I tried batch before going down this route, but either it doesn't work as a queue on OSX, or I was using it wrong.)






            share|improve this answer























            • I realize that @arnaud specified "commodity PC," which means it's probably not OSX, where I tested this solution. However, this should be portable, and it's much more flexible than batch.

              – Joe Fusion
              Jan 28 '14 at 19:35







            • 1





              This is possible one of the most genuine hacks I've ever seen.

              – Thiago Macedo
              Nov 7 '17 at 21:19


















            0














            I notice this question is several years old, so it may not help the original poster, but it may help someone else.



            First: "task spooler" is the answer. It's pretty powerful and Fedora at least has it.



            But a lot of the servers I use, I can't install arbitrary packages without a lot of hassle, so I need something that is ideally pure bash (or perl, or such).



            After struggling with this for a while, I came up with a pure bash implementation that appears to work fine so far. You can find it at https://github.com/sitaramc/bq.



            It's just one bash script so installation is trivial. However, it punts your second and third requirements (but it should be trivial to implement those too).



            The script is liberally commented and you should be able to review it in a few minutes if you wish to.






            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
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f19458%2fsimple-queuing-system%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              7














              There's a standard batch command that does more or less what you're after. More precisely, batch executes the jobs when the system load is not too high, one at a time (so it doesn't do any parallelization). The batch command is part of the at package.



              echo 'command1 --foo=bar' | batch 
              echo 'command2 "$(wibble)"' | batch
              at -q b -l # on many OSes, a slightly shorter synonym is: atq -q b
              at -q b -r 1234 # Unschedule a pending task (atq gives the task ID)





              share|improve this answer























              • It's wrong to say that the batch command "doesn't do any parallelization". There's usually a default 60sec delay between starting one job and starting the next; however, there's nothing to make the next job wait for the first to finish -- atd will happily kick off jobs from the batch queue as soon as the value set by the -b option has elapsed (see atd man page).

                – rsaw
                Apr 26 '16 at 21:35















              7














              There's a standard batch command that does more or less what you're after. More precisely, batch executes the jobs when the system load is not too high, one at a time (so it doesn't do any parallelization). The batch command is part of the at package.



              echo 'command1 --foo=bar' | batch 
              echo 'command2 "$(wibble)"' | batch
              at -q b -l # on many OSes, a slightly shorter synonym is: atq -q b
              at -q b -r 1234 # Unschedule a pending task (atq gives the task ID)





              share|improve this answer























              • It's wrong to say that the batch command "doesn't do any parallelization". There's usually a default 60sec delay between starting one job and starting the next; however, there's nothing to make the next job wait for the first to finish -- atd will happily kick off jobs from the batch queue as soon as the value set by the -b option has elapsed (see atd man page).

                – rsaw
                Apr 26 '16 at 21:35













              7












              7








              7







              There's a standard batch command that does more or less what you're after. More precisely, batch executes the jobs when the system load is not too high, one at a time (so it doesn't do any parallelization). The batch command is part of the at package.



              echo 'command1 --foo=bar' | batch 
              echo 'command2 "$(wibble)"' | batch
              at -q b -l # on many OSes, a slightly shorter synonym is: atq -q b
              at -q b -r 1234 # Unschedule a pending task (atq gives the task ID)





              share|improve this answer













              There's a standard batch command that does more or less what you're after. More precisely, batch executes the jobs when the system load is not too high, one at a time (so it doesn't do any parallelization). The batch command is part of the at package.



              echo 'command1 --foo=bar' | batch 
              echo 'command2 "$(wibble)"' | batch
              at -q b -l # on many OSes, a slightly shorter synonym is: atq -q b
              at -q b -r 1234 # Unschedule a pending task (atq gives the task ID)






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Aug 26 '11 at 22:39









              GillesGilles

              545k12811071622




              545k12811071622












              • It's wrong to say that the batch command "doesn't do any parallelization". There's usually a default 60sec delay between starting one job and starting the next; however, there's nothing to make the next job wait for the first to finish -- atd will happily kick off jobs from the batch queue as soon as the value set by the -b option has elapsed (see atd man page).

                – rsaw
                Apr 26 '16 at 21:35

















              • It's wrong to say that the batch command "doesn't do any parallelization". There's usually a default 60sec delay between starting one job and starting the next; however, there's nothing to make the next job wait for the first to finish -- atd will happily kick off jobs from the batch queue as soon as the value set by the -b option has elapsed (see atd man page).

                – rsaw
                Apr 26 '16 at 21:35
















              It's wrong to say that the batch command "doesn't do any parallelization". There's usually a default 60sec delay between starting one job and starting the next; however, there's nothing to make the next job wait for the first to finish -- atd will happily kick off jobs from the batch queue as soon as the value set by the -b option has elapsed (see atd man page).

              – rsaw
              Apr 26 '16 at 21:35





              It's wrong to say that the batch command "doesn't do any parallelization". There's usually a default 60sec delay between starting one job and starting the next; however, there's nothing to make the next job wait for the first to finish -- atd will happily kick off jobs from the batch queue as soon as the value set by the -b option has elapsed (see atd man page).

              – rsaw
              Apr 26 '16 at 21:35













              3














              There are lots of queuing systems, but the are frequently very specialized.



              You might look into the at scheduler. It's like cron in some ways but it is setup more like a queue for one time jobs than for repeat jobs. It can "schedule" things on criteria other than time, such as system load or sequence of jobs.



              Your favorite distro will almost certainly have packages for it.






              share|improve this answer



























                3














                There are lots of queuing systems, but the are frequently very specialized.



                You might look into the at scheduler. It's like cron in some ways but it is setup more like a queue for one time jobs than for repeat jobs. It can "schedule" things on criteria other than time, such as system load or sequence of jobs.



                Your favorite distro will almost certainly have packages for it.






                share|improve this answer

























                  3












                  3








                  3







                  There are lots of queuing systems, but the are frequently very specialized.



                  You might look into the at scheduler. It's like cron in some ways but it is setup more like a queue for one time jobs than for repeat jobs. It can "schedule" things on criteria other than time, such as system load or sequence of jobs.



                  Your favorite distro will almost certainly have packages for it.






                  share|improve this answer













                  There are lots of queuing systems, but the are frequently very specialized.



                  You might look into the at scheduler. It's like cron in some ways but it is setup more like a queue for one time jobs than for repeat jobs. It can "schedule" things on criteria other than time, such as system load or sequence of jobs.



                  Your favorite distro will almost certainly have packages for it.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 26 '11 at 9:34









                  CalebCaleb

                  51.8k9150194




                  51.8k9150194





















                      2














                      Another solution is to use lpd, and create a custom "print driver" that runs your jobs. A friend helped me work this out when I had a similar request. Make a script like this, and put it in /tmp/batch.sh:



                      #!/bin/bash

                      TMPFILE=$(mktemp /tmp/XXXX)
                      exec <"$6"
                      cat - > $TMPFILE
                      chmod a+x $TMPFILE
                      $TMPFILE
                      rm -f $TMPFILE


                      Then run:



                      lpadmin -p batch1 -E -P /tmp/batch.sh


                      That starts a queue, and you can create more by using other names instead of batch1. Add a job with:



                      lp -d batch1 /path/to/jobscript


                      Manage jobs with lpq, lprm, and lpstat. If you want more flexibility with passing arguments to your jobs, you can make the batch.sh script fancier.



                      (I tried batch before going down this route, but either it doesn't work as a queue on OSX, or I was using it wrong.)






                      share|improve this answer























                      • I realize that @arnaud specified "commodity PC," which means it's probably not OSX, where I tested this solution. However, this should be portable, and it's much more flexible than batch.

                        – Joe Fusion
                        Jan 28 '14 at 19:35







                      • 1





                        This is possible one of the most genuine hacks I've ever seen.

                        – Thiago Macedo
                        Nov 7 '17 at 21:19















                      2














                      Another solution is to use lpd, and create a custom "print driver" that runs your jobs. A friend helped me work this out when I had a similar request. Make a script like this, and put it in /tmp/batch.sh:



                      #!/bin/bash

                      TMPFILE=$(mktemp /tmp/XXXX)
                      exec <"$6"
                      cat - > $TMPFILE
                      chmod a+x $TMPFILE
                      $TMPFILE
                      rm -f $TMPFILE


                      Then run:



                      lpadmin -p batch1 -E -P /tmp/batch.sh


                      That starts a queue, and you can create more by using other names instead of batch1. Add a job with:



                      lp -d batch1 /path/to/jobscript


                      Manage jobs with lpq, lprm, and lpstat. If you want more flexibility with passing arguments to your jobs, you can make the batch.sh script fancier.



                      (I tried batch before going down this route, but either it doesn't work as a queue on OSX, or I was using it wrong.)






                      share|improve this answer























                      • I realize that @arnaud specified "commodity PC," which means it's probably not OSX, where I tested this solution. However, this should be portable, and it's much more flexible than batch.

                        – Joe Fusion
                        Jan 28 '14 at 19:35







                      • 1





                        This is possible one of the most genuine hacks I've ever seen.

                        – Thiago Macedo
                        Nov 7 '17 at 21:19













                      2












                      2








                      2







                      Another solution is to use lpd, and create a custom "print driver" that runs your jobs. A friend helped me work this out when I had a similar request. Make a script like this, and put it in /tmp/batch.sh:



                      #!/bin/bash

                      TMPFILE=$(mktemp /tmp/XXXX)
                      exec <"$6"
                      cat - > $TMPFILE
                      chmod a+x $TMPFILE
                      $TMPFILE
                      rm -f $TMPFILE


                      Then run:



                      lpadmin -p batch1 -E -P /tmp/batch.sh


                      That starts a queue, and you can create more by using other names instead of batch1. Add a job with:



                      lp -d batch1 /path/to/jobscript


                      Manage jobs with lpq, lprm, and lpstat. If you want more flexibility with passing arguments to your jobs, you can make the batch.sh script fancier.



                      (I tried batch before going down this route, but either it doesn't work as a queue on OSX, or I was using it wrong.)






                      share|improve this answer













                      Another solution is to use lpd, and create a custom "print driver" that runs your jobs. A friend helped me work this out when I had a similar request. Make a script like this, and put it in /tmp/batch.sh:



                      #!/bin/bash

                      TMPFILE=$(mktemp /tmp/XXXX)
                      exec <"$6"
                      cat - > $TMPFILE
                      chmod a+x $TMPFILE
                      $TMPFILE
                      rm -f $TMPFILE


                      Then run:



                      lpadmin -p batch1 -E -P /tmp/batch.sh


                      That starts a queue, and you can create more by using other names instead of batch1. Add a job with:



                      lp -d batch1 /path/to/jobscript


                      Manage jobs with lpq, lprm, and lpstat. If you want more flexibility with passing arguments to your jobs, you can make the batch.sh script fancier.



                      (I tried batch before going down this route, but either it doesn't work as a queue on OSX, or I was using it wrong.)







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 28 '14 at 19:19









                      Joe FusionJoe Fusion

                      213




                      213












                      • I realize that @arnaud specified "commodity PC," which means it's probably not OSX, where I tested this solution. However, this should be portable, and it's much more flexible than batch.

                        – Joe Fusion
                        Jan 28 '14 at 19:35







                      • 1





                        This is possible one of the most genuine hacks I've ever seen.

                        – Thiago Macedo
                        Nov 7 '17 at 21:19

















                      • I realize that @arnaud specified "commodity PC," which means it's probably not OSX, where I tested this solution. However, this should be portable, and it's much more flexible than batch.

                        – Joe Fusion
                        Jan 28 '14 at 19:35







                      • 1





                        This is possible one of the most genuine hacks I've ever seen.

                        – Thiago Macedo
                        Nov 7 '17 at 21:19
















                      I realize that @arnaud specified "commodity PC," which means it's probably not OSX, where I tested this solution. However, this should be portable, and it's much more flexible than batch.

                      – Joe Fusion
                      Jan 28 '14 at 19:35






                      I realize that @arnaud specified "commodity PC," which means it's probably not OSX, where I tested this solution. However, this should be portable, and it's much more flexible than batch.

                      – Joe Fusion
                      Jan 28 '14 at 19:35





                      1




                      1





                      This is possible one of the most genuine hacks I've ever seen.

                      – Thiago Macedo
                      Nov 7 '17 at 21:19





                      This is possible one of the most genuine hacks I've ever seen.

                      – Thiago Macedo
                      Nov 7 '17 at 21:19











                      0














                      I notice this question is several years old, so it may not help the original poster, but it may help someone else.



                      First: "task spooler" is the answer. It's pretty powerful and Fedora at least has it.



                      But a lot of the servers I use, I can't install arbitrary packages without a lot of hassle, so I need something that is ideally pure bash (or perl, or such).



                      After struggling with this for a while, I came up with a pure bash implementation that appears to work fine so far. You can find it at https://github.com/sitaramc/bq.



                      It's just one bash script so installation is trivial. However, it punts your second and third requirements (but it should be trivial to implement those too).



                      The script is liberally commented and you should be able to review it in a few minutes if you wish to.






                      share|improve this answer



























                        0














                        I notice this question is several years old, so it may not help the original poster, but it may help someone else.



                        First: "task spooler" is the answer. It's pretty powerful and Fedora at least has it.



                        But a lot of the servers I use, I can't install arbitrary packages without a lot of hassle, so I need something that is ideally pure bash (or perl, or such).



                        After struggling with this for a while, I came up with a pure bash implementation that appears to work fine so far. You can find it at https://github.com/sitaramc/bq.



                        It's just one bash script so installation is trivial. However, it punts your second and third requirements (but it should be trivial to implement those too).



                        The script is liberally commented and you should be able to review it in a few minutes if you wish to.






                        share|improve this answer

























                          0












                          0








                          0







                          I notice this question is several years old, so it may not help the original poster, but it may help someone else.



                          First: "task spooler" is the answer. It's pretty powerful and Fedora at least has it.



                          But a lot of the servers I use, I can't install arbitrary packages without a lot of hassle, so I need something that is ideally pure bash (or perl, or such).



                          After struggling with this for a while, I came up with a pure bash implementation that appears to work fine so far. You can find it at https://github.com/sitaramc/bq.



                          It's just one bash script so installation is trivial. However, it punts your second and third requirements (but it should be trivial to implement those too).



                          The script is liberally commented and you should be able to review it in a few minutes if you wish to.






                          share|improve this answer













                          I notice this question is several years old, so it may not help the original poster, but it may help someone else.



                          First: "task spooler" is the answer. It's pretty powerful and Fedora at least has it.



                          But a lot of the servers I use, I can't install arbitrary packages without a lot of hassle, so I need something that is ideally pure bash (or perl, or such).



                          After struggling with this for a while, I came up with a pure bash implementation that appears to work fine so far. You can find it at https://github.com/sitaramc/bq.



                          It's just one bash script so installation is trivial. However, it punts your second and third requirements (but it should be trivial to implement those too).



                          The script is liberally commented and you should be able to review it in a few minutes if you wish to.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 3 at 2:46









                          sitaramsitaram

                          11




                          11



























                              draft saved

                              draft discarded
















































                              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%2f19458%2fsimple-queuing-system%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

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

                              Displaying single band from multi-band raster using QGIS

                              How many registers does an x86_64 CPU actually have?