Why my cron routine doesn't work












0















When I put



* * * * * /var/www/script.sh 


Script is executed once per minute, but if I put



* */2 * * * /var/www/script.sh 


instead, script doesn't execute at all










share|improve this question









New contributor




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
















  • 3





    How long did you wait? * */2 * * * would mean every minute of every even hour (i.e. when the hour is divisible by 2) - it won't run at all if the hour is odd

    – steeldriver
    Jan 21 at 15:10













  • I want it to run once per hour. I was waiting one day now.

    – kubawich
    Jan 21 at 15:12











  • You could send the full output to a log file like this * */2 * * * /var/www/script.sh >> /path/to/file.log 2>&1. That way you can see if there's any permission issue, and/or a bash programing one.

    – bistoco
    Jan 21 at 15:13






  • 2





    For "once per hour", just change the first * to any valid minute (from 0-59) and leave the hour field as *

    – steeldriver
    Jan 21 at 15:15
















0















When I put



* * * * * /var/www/script.sh 


Script is executed once per minute, but if I put



* */2 * * * /var/www/script.sh 


instead, script doesn't execute at all










share|improve this question









New contributor




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
















  • 3





    How long did you wait? * */2 * * * would mean every minute of every even hour (i.e. when the hour is divisible by 2) - it won't run at all if the hour is odd

    – steeldriver
    Jan 21 at 15:10













  • I want it to run once per hour. I was waiting one day now.

    – kubawich
    Jan 21 at 15:12











  • You could send the full output to a log file like this * */2 * * * /var/www/script.sh >> /path/to/file.log 2>&1. That way you can see if there's any permission issue, and/or a bash programing one.

    – bistoco
    Jan 21 at 15:13






  • 2





    For "once per hour", just change the first * to any valid minute (from 0-59) and leave the hour field as *

    – steeldriver
    Jan 21 at 15:15














0












0








0








When I put



* * * * * /var/www/script.sh 


Script is executed once per minute, but if I put



* */2 * * * /var/www/script.sh 


instead, script doesn't execute at all










share|improve this question









New contributor




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












When I put



* * * * * /var/www/script.sh 


Script is executed once per minute, but if I put



* */2 * * * /var/www/script.sh 


instead, script doesn't execute at all







cron






share|improve this question









New contributor




kubawich 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




kubawich 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








edited Jan 21 at 15:08









steeldriver

67k11108180




67k11108180






New contributor




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









asked Jan 21 at 15:04









kubawichkubawich

31




31




New contributor




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





New contributor





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






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








  • 3





    How long did you wait? * */2 * * * would mean every minute of every even hour (i.e. when the hour is divisible by 2) - it won't run at all if the hour is odd

    – steeldriver
    Jan 21 at 15:10













  • I want it to run once per hour. I was waiting one day now.

    – kubawich
    Jan 21 at 15:12











  • You could send the full output to a log file like this * */2 * * * /var/www/script.sh >> /path/to/file.log 2>&1. That way you can see if there's any permission issue, and/or a bash programing one.

    – bistoco
    Jan 21 at 15:13






  • 2





    For "once per hour", just change the first * to any valid minute (from 0-59) and leave the hour field as *

    – steeldriver
    Jan 21 at 15:15














  • 3





    How long did you wait? * */2 * * * would mean every minute of every even hour (i.e. when the hour is divisible by 2) - it won't run at all if the hour is odd

    – steeldriver
    Jan 21 at 15:10













  • I want it to run once per hour. I was waiting one day now.

    – kubawich
    Jan 21 at 15:12











  • You could send the full output to a log file like this * */2 * * * /var/www/script.sh >> /path/to/file.log 2>&1. That way you can see if there's any permission issue, and/or a bash programing one.

    – bistoco
    Jan 21 at 15:13






  • 2





    For "once per hour", just change the first * to any valid minute (from 0-59) and leave the hour field as *

    – steeldriver
    Jan 21 at 15:15








3




3





How long did you wait? * */2 * * * would mean every minute of every even hour (i.e. when the hour is divisible by 2) - it won't run at all if the hour is odd

– steeldriver
Jan 21 at 15:10







How long did you wait? * */2 * * * would mean every minute of every even hour (i.e. when the hour is divisible by 2) - it won't run at all if the hour is odd

– steeldriver
Jan 21 at 15:10















I want it to run once per hour. I was waiting one day now.

– kubawich
Jan 21 at 15:12





I want it to run once per hour. I was waiting one day now.

– kubawich
Jan 21 at 15:12













You could send the full output to a log file like this * */2 * * * /var/www/script.sh >> /path/to/file.log 2>&1. That way you can see if there's any permission issue, and/or a bash programing one.

– bistoco
Jan 21 at 15:13





You could send the full output to a log file like this * */2 * * * /var/www/script.sh >> /path/to/file.log 2>&1. That way you can see if there's any permission issue, and/or a bash programing one.

– bistoco
Jan 21 at 15:13




2




2





For "once per hour", just change the first * to any valid minute (from 0-59) and leave the hour field as *

– steeldriver
Jan 21 at 15:15





For "once per hour", just change the first * to any valid minute (from 0-59) and leave the hour field as *

– steeldriver
Jan 21 at 15:15










2 Answers
2






active

oldest

votes


















0














You are supposed to change the '*' out for the number. Therefore your second asterix should be 2 so:



* 2 * * * /var/www/script.sh


and not



* */2 * * * /var/www/script.sh


For future reference
The first asterisk is for specifying the minute of the run (0-59)
The second asterisk is for specifying the hour of the run (0-23)
The third asterisk is for specifying the day of the month for the run (1-31)
The fourth asterisk is for specifying the month of the run (1-12)
The fifth asterisk is for specifying the day of the week (where Sunday is equal






share|improve this answer


























  • I guess it's correct if You want to run script at 2am everyday, but i want my script to run once per hour/two hours

    – kubawich
    Jan 21 at 15:11











  • Ok so you are correct with the syntax. and I am guessing you waited 2 hours to check right ? AS what you are doing is to run cron minute after every 2 hours. Is there nothing in syslog as for the execution of the script ?

    – Oskar L
    Jan 21 at 15:14











  • How can i check it?

    – kubawich
    Jan 21 at 15:20











  • Try this one: 1 */2 * * *

    – Oskar L
    Jan 21 at 15:22






  • 2





    I wonder why this is the accepted answer. The OP said "I want it to run once per hour." and * 2 * * * runs it every single minute from 2AM to 2:59AM. Completely different cases.

    – PerlDuck
    Jan 21 at 16:19



















2














If you want it to run every hour, then you need a number in the minute field. To run it at quarter past the hour, for example, use:



15 * * * * /var/www/script.sh


From man -i 5 crontab:



   Commands are executed by cron(8) when the minute, hour, and month of year fields match the  current
time, and when at least one of the two day fields (day of month, or day of week) match the current
time (see ``Note'' below). cron(8) examines cron entries once every minute. The time and date
fields are:

field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

A field may be an asterisk (*), which always stands for ``first-last''.

Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified
range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10
and 11.

Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples:
``1,2,5,9'', ``0-4,8-12''.

Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies
skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours
field to specify command execution every other hour (the alternative in the V7 standard is
``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to
say ``every two hours'', just use ``*/2''.





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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: 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
    });


    }
    });






    kubawich 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%2faskubuntu.com%2fquestions%2f1111679%2fwhy-my-cron-routine-doesnt-work%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









    0














    You are supposed to change the '*' out for the number. Therefore your second asterix should be 2 so:



    * 2 * * * /var/www/script.sh


    and not



    * */2 * * * /var/www/script.sh


    For future reference
    The first asterisk is for specifying the minute of the run (0-59)
    The second asterisk is for specifying the hour of the run (0-23)
    The third asterisk is for specifying the day of the month for the run (1-31)
    The fourth asterisk is for specifying the month of the run (1-12)
    The fifth asterisk is for specifying the day of the week (where Sunday is equal






    share|improve this answer


























    • I guess it's correct if You want to run script at 2am everyday, but i want my script to run once per hour/two hours

      – kubawich
      Jan 21 at 15:11











    • Ok so you are correct with the syntax. and I am guessing you waited 2 hours to check right ? AS what you are doing is to run cron minute after every 2 hours. Is there nothing in syslog as for the execution of the script ?

      – Oskar L
      Jan 21 at 15:14











    • How can i check it?

      – kubawich
      Jan 21 at 15:20











    • Try this one: 1 */2 * * *

      – Oskar L
      Jan 21 at 15:22






    • 2





      I wonder why this is the accepted answer. The OP said "I want it to run once per hour." and * 2 * * * runs it every single minute from 2AM to 2:59AM. Completely different cases.

      – PerlDuck
      Jan 21 at 16:19
















    0














    You are supposed to change the '*' out for the number. Therefore your second asterix should be 2 so:



    * 2 * * * /var/www/script.sh


    and not



    * */2 * * * /var/www/script.sh


    For future reference
    The first asterisk is for specifying the minute of the run (0-59)
    The second asterisk is for specifying the hour of the run (0-23)
    The third asterisk is for specifying the day of the month for the run (1-31)
    The fourth asterisk is for specifying the month of the run (1-12)
    The fifth asterisk is for specifying the day of the week (where Sunday is equal






    share|improve this answer


























    • I guess it's correct if You want to run script at 2am everyday, but i want my script to run once per hour/two hours

      – kubawich
      Jan 21 at 15:11











    • Ok so you are correct with the syntax. and I am guessing you waited 2 hours to check right ? AS what you are doing is to run cron minute after every 2 hours. Is there nothing in syslog as for the execution of the script ?

      – Oskar L
      Jan 21 at 15:14











    • How can i check it?

      – kubawich
      Jan 21 at 15:20











    • Try this one: 1 */2 * * *

      – Oskar L
      Jan 21 at 15:22






    • 2





      I wonder why this is the accepted answer. The OP said "I want it to run once per hour." and * 2 * * * runs it every single minute from 2AM to 2:59AM. Completely different cases.

      – PerlDuck
      Jan 21 at 16:19














    0












    0








    0







    You are supposed to change the '*' out for the number. Therefore your second asterix should be 2 so:



    * 2 * * * /var/www/script.sh


    and not



    * */2 * * * /var/www/script.sh


    For future reference
    The first asterisk is for specifying the minute of the run (0-59)
    The second asterisk is for specifying the hour of the run (0-23)
    The third asterisk is for specifying the day of the month for the run (1-31)
    The fourth asterisk is for specifying the month of the run (1-12)
    The fifth asterisk is for specifying the day of the week (where Sunday is equal






    share|improve this answer















    You are supposed to change the '*' out for the number. Therefore your second asterix should be 2 so:



    * 2 * * * /var/www/script.sh


    and not



    * */2 * * * /var/www/script.sh


    For future reference
    The first asterisk is for specifying the minute of the run (0-59)
    The second asterisk is for specifying the hour of the run (0-23)
    The third asterisk is for specifying the day of the month for the run (1-31)
    The fourth asterisk is for specifying the month of the run (1-12)
    The fifth asterisk is for specifying the day of the week (where Sunday is equal







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 21 at 15:17

























    answered Jan 21 at 15:07









    Oskar LOskar L

    1026




    1026













    • I guess it's correct if You want to run script at 2am everyday, but i want my script to run once per hour/two hours

      – kubawich
      Jan 21 at 15:11











    • Ok so you are correct with the syntax. and I am guessing you waited 2 hours to check right ? AS what you are doing is to run cron minute after every 2 hours. Is there nothing in syslog as for the execution of the script ?

      – Oskar L
      Jan 21 at 15:14











    • How can i check it?

      – kubawich
      Jan 21 at 15:20











    • Try this one: 1 */2 * * *

      – Oskar L
      Jan 21 at 15:22






    • 2





      I wonder why this is the accepted answer. The OP said "I want it to run once per hour." and * 2 * * * runs it every single minute from 2AM to 2:59AM. Completely different cases.

      – PerlDuck
      Jan 21 at 16:19



















    • I guess it's correct if You want to run script at 2am everyday, but i want my script to run once per hour/two hours

      – kubawich
      Jan 21 at 15:11











    • Ok so you are correct with the syntax. and I am guessing you waited 2 hours to check right ? AS what you are doing is to run cron minute after every 2 hours. Is there nothing in syslog as for the execution of the script ?

      – Oskar L
      Jan 21 at 15:14











    • How can i check it?

      – kubawich
      Jan 21 at 15:20











    • Try this one: 1 */2 * * *

      – Oskar L
      Jan 21 at 15:22






    • 2





      I wonder why this is the accepted answer. The OP said "I want it to run once per hour." and * 2 * * * runs it every single minute from 2AM to 2:59AM. Completely different cases.

      – PerlDuck
      Jan 21 at 16:19

















    I guess it's correct if You want to run script at 2am everyday, but i want my script to run once per hour/two hours

    – kubawich
    Jan 21 at 15:11





    I guess it's correct if You want to run script at 2am everyday, but i want my script to run once per hour/two hours

    – kubawich
    Jan 21 at 15:11













    Ok so you are correct with the syntax. and I am guessing you waited 2 hours to check right ? AS what you are doing is to run cron minute after every 2 hours. Is there nothing in syslog as for the execution of the script ?

    – Oskar L
    Jan 21 at 15:14





    Ok so you are correct with the syntax. and I am guessing you waited 2 hours to check right ? AS what you are doing is to run cron minute after every 2 hours. Is there nothing in syslog as for the execution of the script ?

    – Oskar L
    Jan 21 at 15:14













    How can i check it?

    – kubawich
    Jan 21 at 15:20





    How can i check it?

    – kubawich
    Jan 21 at 15:20













    Try this one: 1 */2 * * *

    – Oskar L
    Jan 21 at 15:22





    Try this one: 1 */2 * * *

    – Oskar L
    Jan 21 at 15:22




    2




    2





    I wonder why this is the accepted answer. The OP said "I want it to run once per hour." and * 2 * * * runs it every single minute from 2AM to 2:59AM. Completely different cases.

    – PerlDuck
    Jan 21 at 16:19





    I wonder why this is the accepted answer. The OP said "I want it to run once per hour." and * 2 * * * runs it every single minute from 2AM to 2:59AM. Completely different cases.

    – PerlDuck
    Jan 21 at 16:19













    2














    If you want it to run every hour, then you need a number in the minute field. To run it at quarter past the hour, for example, use:



    15 * * * * /var/www/script.sh


    From man -i 5 crontab:



       Commands are executed by cron(8) when the minute, hour, and month of year fields match the  current
    time, and when at least one of the two day fields (day of month, or day of week) match the current
    time (see ``Note'' below). cron(8) examines cron entries once every minute. The time and date
    fields are:

    field allowed values
    ----- --------------
    minute 0-59
    hour 0-23
    day of month 1-31
    month 1-12 (or names, see below)
    day of week 0-7 (0 or 7 is Sun, or use names)

    A field may be an asterisk (*), which always stands for ``first-last''.

    Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified
    range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10
    and 11.

    Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples:
    ``1,2,5,9'', ``0-4,8-12''.

    Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies
    skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours
    field to specify command execution every other hour (the alternative in the V7 standard is
    ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to
    say ``every two hours'', just use ``*/2''.





    share|improve this answer




























      2














      If you want it to run every hour, then you need a number in the minute field. To run it at quarter past the hour, for example, use:



      15 * * * * /var/www/script.sh


      From man -i 5 crontab:



         Commands are executed by cron(8) when the minute, hour, and month of year fields match the  current
      time, and when at least one of the two day fields (day of month, or day of week) match the current
      time (see ``Note'' below). cron(8) examines cron entries once every minute. The time and date
      fields are:

      field allowed values
      ----- --------------
      minute 0-59
      hour 0-23
      day of month 1-31
      month 1-12 (or names, see below)
      day of week 0-7 (0 or 7 is Sun, or use names)

      A field may be an asterisk (*), which always stands for ``first-last''.

      Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified
      range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10
      and 11.

      Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples:
      ``1,2,5,9'', ``0-4,8-12''.

      Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies
      skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours
      field to specify command execution every other hour (the alternative in the V7 standard is
      ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to
      say ``every two hours'', just use ``*/2''.





      share|improve this answer


























        2












        2








        2







        If you want it to run every hour, then you need a number in the minute field. To run it at quarter past the hour, for example, use:



        15 * * * * /var/www/script.sh


        From man -i 5 crontab:



           Commands are executed by cron(8) when the minute, hour, and month of year fields match the  current
        time, and when at least one of the two day fields (day of month, or day of week) match the current
        time (see ``Note'' below). cron(8) examines cron entries once every minute. The time and date
        fields are:

        field allowed values
        ----- --------------
        minute 0-59
        hour 0-23
        day of month 1-31
        month 1-12 (or names, see below)
        day of week 0-7 (0 or 7 is Sun, or use names)

        A field may be an asterisk (*), which always stands for ``first-last''.

        Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified
        range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10
        and 11.

        Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples:
        ``1,2,5,9'', ``0-4,8-12''.

        Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies
        skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours
        field to specify command execution every other hour (the alternative in the V7 standard is
        ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to
        say ``every two hours'', just use ``*/2''.





        share|improve this answer













        If you want it to run every hour, then you need a number in the minute field. To run it at quarter past the hour, for example, use:



        15 * * * * /var/www/script.sh


        From man -i 5 crontab:



           Commands are executed by cron(8) when the minute, hour, and month of year fields match the  current
        time, and when at least one of the two day fields (day of month, or day of week) match the current
        time (see ``Note'' below). cron(8) examines cron entries once every minute. The time and date
        fields are:

        field allowed values
        ----- --------------
        minute 0-59
        hour 0-23
        day of month 1-31
        month 1-12 (or names, see below)
        day of week 0-7 (0 or 7 is Sun, or use names)

        A field may be an asterisk (*), which always stands for ``first-last''.

        Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified
        range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10
        and 11.

        Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples:
        ``1,2,5,9'', ``0-4,8-12''.

        Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies
        skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours
        field to specify command execution every other hour (the alternative in the V7 standard is
        ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to
        say ``every two hours'', just use ``*/2''.






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 21 at 15:18









        bitinerantbitinerant

        1113




        1113






















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










            draft saved

            draft discarded


















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













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












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
















            Thanks for contributing an answer to Ask Ubuntu!


            • 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%2faskubuntu.com%2fquestions%2f1111679%2fwhy-my-cron-routine-doesnt-work%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

            數位音樂下載

            When can things happen in Etherscan, such as the picture below?

            格利澤436b