Make the daily log rotate run on exact time












0















I have Ubuntu 12.04.2 LTS server.



My daily log rotations which are listed under /etc/logrotate.d/ are executed at the morning around 7:00 am, but it is not on exact time, each day it changed on range of (07:00 - 07:25), How can I prevent the random time execution of log rotation?



/etc/crontab file content:



SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
0 7 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )


/etc/cron.daily/logrotate content:



#!/bin/sh

# Clean non existent log file entries from status file
cd /var/lib/logrotate
test -e status || touch status
head -1 status > status.clean
sed 's/"//g' status | while read logfile date
do
[ -e "$logfile" ] && echo ""$logfile" $date"
done >> status.clean
mv status.clean status

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf


Related thread:
Specify the time of daily log rotate










share|improve this question
















bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I have Ubuntu 12.04.2 LTS server.



    My daily log rotations which are listed under /etc/logrotate.d/ are executed at the morning around 7:00 am, but it is not on exact time, each day it changed on range of (07:00 - 07:25), How can I prevent the random time execution of log rotation?



    /etc/crontab file content:



    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

    # m h dom mon dow user command
    17 * * * * root cd / && run-parts --report /etc/cron.hourly
    0 7 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
    47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
    52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )


    /etc/cron.daily/logrotate content:



    #!/bin/sh

    # Clean non existent log file entries from status file
    cd /var/lib/logrotate
    test -e status || touch status
    head -1 status > status.clean
    sed 's/"//g' status | while read logfile date
    do
    [ -e "$logfile" ] && echo ""$logfile" $date"
    done >> status.clean
    mv status.clean status

    test -x /usr/sbin/logrotate || exit 0
    /usr/sbin/logrotate /etc/logrotate.conf


    Related thread:
    Specify the time of daily log rotate










    share|improve this question
















    bumped to the homepage by Community 2 hours ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I have Ubuntu 12.04.2 LTS server.



      My daily log rotations which are listed under /etc/logrotate.d/ are executed at the morning around 7:00 am, but it is not on exact time, each day it changed on range of (07:00 - 07:25), How can I prevent the random time execution of log rotation?



      /etc/crontab file content:



      SHELL=/bin/sh
      PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

      # m h dom mon dow user command
      17 * * * * root cd / && run-parts --report /etc/cron.hourly
      0 7 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
      47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
      52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )


      /etc/cron.daily/logrotate content:



      #!/bin/sh

      # Clean non existent log file entries from status file
      cd /var/lib/logrotate
      test -e status || touch status
      head -1 status > status.clean
      sed 's/"//g' status | while read logfile date
      do
      [ -e "$logfile" ] && echo ""$logfile" $date"
      done >> status.clean
      mv status.clean status

      test -x /usr/sbin/logrotate || exit 0
      /usr/sbin/logrotate /etc/logrotate.conf


      Related thread:
      Specify the time of daily log rotate










      share|improve this question
















      I have Ubuntu 12.04.2 LTS server.



      My daily log rotations which are listed under /etc/logrotate.d/ are executed at the morning around 7:00 am, but it is not on exact time, each day it changed on range of (07:00 - 07:25), How can I prevent the random time execution of log rotation?



      /etc/crontab file content:



      SHELL=/bin/sh
      PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

      # m h dom mon dow user command
      17 * * * * root cd / && run-parts --report /etc/cron.hourly
      0 7 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
      47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
      52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )


      /etc/cron.daily/logrotate content:



      #!/bin/sh

      # Clean non existent log file entries from status file
      cd /var/lib/logrotate
      test -e status || touch status
      head -1 status > status.clean
      sed 's/"//g' status | while read logfile date
      do
      [ -e "$logfile" ] && echo ""$logfile" $date"
      done >> status.clean
      mv status.clean status

      test -x /usr/sbin/logrotate || exit 0
      /usr/sbin/logrotate /etc/logrotate.conf


      Related thread:
      Specify the time of daily log rotate







      scripts cron log compression logrotate






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 13 '17 at 12:24









      Community

      1




      1










      asked Sep 24 '13 at 7:24









      Khaled ZoabiKhaled Zoabi

      113




      113





      bumped to the homepage by Community 2 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 2 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The /etc/cron.daily folder contains dozens of items (17 items in my box), and logrotate is not guaranteed to run at first.



          So if you want logrotate to run exactly the same time everyday, make it as a single entry in the crontab as in the Related thread: Specify the time of daily log rotate






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


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f349382%2fmake-the-daily-log-rotate-run-on-exact-time%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The /etc/cron.daily folder contains dozens of items (17 items in my box), and logrotate is not guaranteed to run at first.



            So if you want logrotate to run exactly the same time everyday, make it as a single entry in the crontab as in the Related thread: Specify the time of daily log rotate






            share|improve this answer






























              0














              The /etc/cron.daily folder contains dozens of items (17 items in my box), and logrotate is not guaranteed to run at first.



              So if you want logrotate to run exactly the same time everyday, make it as a single entry in the crontab as in the Related thread: Specify the time of daily log rotate






              share|improve this answer




























                0












                0








                0







                The /etc/cron.daily folder contains dozens of items (17 items in my box), and logrotate is not guaranteed to run at first.



                So if you want logrotate to run exactly the same time everyday, make it as a single entry in the crontab as in the Related thread: Specify the time of daily log rotate






                share|improve this answer















                The /etc/cron.daily folder contains dozens of items (17 items in my box), and logrotate is not guaranteed to run at first.



                So if you want logrotate to run exactly the same time everyday, make it as a single entry in the crontab as in the Related thread: Specify the time of daily log rotate







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 13 '17 at 12:23









                Community

                1




                1










                answered May 12 '14 at 16:19









                Ben LinBen Lin

                21712




                21712






























                    draft saved

                    draft discarded




















































                    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%2f349382%2fmake-the-daily-log-rotate-run-on-exact-time%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

                    GameSpot

                    日野市

                    Tu-95轟炸機