Set a cron every certain hours between certain hours











up vote
53
down vote

favorite
19












How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?










share|improve this question













migrated from stackoverflow.com Apr 11 '12 at 23:53


This question came from our site for professional and enthusiast programmers.











  • 9




    please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
    – luqita
    Apr 11 '12 at 17:41






  • 5




    I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
    – bh5k
    Nov 28 '12 at 16:51















up vote
53
down vote

favorite
19












How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?










share|improve this question













migrated from stackoverflow.com Apr 11 '12 at 23:53


This question came from our site for professional and enthusiast programmers.











  • 9




    please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
    – luqita
    Apr 11 '12 at 17:41






  • 5




    I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
    – bh5k
    Nov 28 '12 at 16:51













up vote
53
down vote

favorite
19









up vote
53
down vote

favorite
19






19





How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?










share|improve this question













How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?







cron






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 11 '12 at 17:31









luqita

376136




376136




migrated from stackoverflow.com Apr 11 '12 at 23:53


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Apr 11 '12 at 23:53


This question came from our site for professional and enthusiast programmers.










  • 9




    please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
    – luqita
    Apr 11 '12 at 17:41






  • 5




    I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
    – bh5k
    Nov 28 '12 at 16:51














  • 9




    please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
    – luqita
    Apr 11 '12 at 17:41






  • 5




    I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
    – bh5k
    Nov 28 '12 at 16:51








9




9




please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
– luqita
Apr 11 '12 at 17:41




please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
– luqita
Apr 11 '12 at 17:41




5




5




I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
– bh5k
Nov 28 '12 at 16:51




I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
– bh5k
Nov 28 '12 at 16:51










2 Answers
2






active

oldest

votes

















up vote
68
down vote













Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm
The right solution is:



0 8-17/2 * * * /path/command


Or even:



0 8,10,12,14,16 * * * /path/command


Which of course looks less nice, but still does what requested...






share|improve this answer























  • Why is it considered to be between 8am and 3pm if it will run at 4pm?
    – Aleksey
    Nov 25 '16 at 13:04












  • @Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
    – DarkAjax
    Nov 26 '16 at 22:06


















up vote
5
down vote













0 8-17/2 * * * your_command.sh





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fsuperuser.com%2fquestions%2f411406%2fset-a-cron-every-certain-hours-between-certain-hours%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








    up vote
    68
    down vote













    Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm
    The right solution is:



    0 8-17/2 * * * /path/command


    Or even:



    0 8,10,12,14,16 * * * /path/command


    Which of course looks less nice, but still does what requested...






    share|improve this answer























    • Why is it considered to be between 8am and 3pm if it will run at 4pm?
      – Aleksey
      Nov 25 '16 at 13:04












    • @Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
      – DarkAjax
      Nov 26 '16 at 22:06















    up vote
    68
    down vote













    Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm
    The right solution is:



    0 8-17/2 * * * /path/command


    Or even:



    0 8,10,12,14,16 * * * /path/command


    Which of course looks less nice, but still does what requested...






    share|improve this answer























    • Why is it considered to be between 8am and 3pm if it will run at 4pm?
      – Aleksey
      Nov 25 '16 at 13:04












    • @Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
      – DarkAjax
      Nov 26 '16 at 22:06













    up vote
    68
    down vote










    up vote
    68
    down vote









    Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm
    The right solution is:



    0 8-17/2 * * * /path/command


    Or even:



    0 8,10,12,14,16 * * * /path/command


    Which of course looks less nice, but still does what requested...






    share|improve this answer














    Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm
    The right solution is:



    0 8-17/2 * * * /path/command


    Or even:



    0 8,10,12,14,16 * * * /path/command


    Which of course looks less nice, but still does what requested...







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 21 at 2:50









    Scott

    15.5k113789




    15.5k113789










    answered Aug 27 '12 at 21:43









    DarkAjax

    881711




    881711












    • Why is it considered to be between 8am and 3pm if it will run at 4pm?
      – Aleksey
      Nov 25 '16 at 13:04












    • @Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
      – DarkAjax
      Nov 26 '16 at 22:06


















    • Why is it considered to be between 8am and 3pm if it will run at 4pm?
      – Aleksey
      Nov 25 '16 at 13:04












    • @Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
      – DarkAjax
      Nov 26 '16 at 22:06
















    Why is it considered to be between 8am and 3pm if it will run at 4pm?
    – Aleksey
    Nov 25 '16 at 13:04






    Why is it considered to be between 8am and 3pm if it will run at 4pm?
    – Aleksey
    Nov 25 '16 at 13:04














    @Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
    – DarkAjax
    Nov 26 '16 at 22:06




    @Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
    – DarkAjax
    Nov 26 '16 at 22:06












    up vote
    5
    down vote













    0 8-17/2 * * * your_command.sh





    share|improve this answer



























      up vote
      5
      down vote













      0 8-17/2 * * * your_command.sh





      share|improve this answer

























        up vote
        5
        down vote










        up vote
        5
        down vote









        0 8-17/2 * * * your_command.sh





        share|improve this answer














        0 8-17/2 * * * your_command.sh






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jul 17 '14 at 16:30

























        answered Apr 11 '12 at 17:47









        Alex

        256310




        256310






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2fsuperuser.com%2fquestions%2f411406%2fset-a-cron-every-certain-hours-between-certain-hours%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

            Plaza Victoria

            In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

            How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...