How can I prevent myself from booting a certain distro in some particular hours?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I have a dual boot setup: Manjaro KDE and Elementary OS.



Let's say I'd like to prevent Manjaro KDE from booting at a certain time (for example between 8:00 AM - 1:00 PM) so that only Elementary OS can be used in that particular time.



Since I think I can't act at GRUB level, Manjaro must certainly be able to boot but then some piece of software should prevent the user from logging in or making the distro unusable at that particular time.



Is this possible? What could I do?










share|improve this question




















  • 1





    Just an hint: for example you can put a check on the time when you boot in KDE. If it is not passed you can change the boot default option (with zero waiting time) and reboot. Give it a look to this answer. Add a check on crontab and reboot if in the wrong time window.

    – Hastur
    Feb 8 at 9:40




















2















I have a dual boot setup: Manjaro KDE and Elementary OS.



Let's say I'd like to prevent Manjaro KDE from booting at a certain time (for example between 8:00 AM - 1:00 PM) so that only Elementary OS can be used in that particular time.



Since I think I can't act at GRUB level, Manjaro must certainly be able to boot but then some piece of software should prevent the user from logging in or making the distro unusable at that particular time.



Is this possible? What could I do?










share|improve this question




















  • 1





    Just an hint: for example you can put a check on the time when you boot in KDE. If it is not passed you can change the boot default option (with zero waiting time) and reboot. Give it a look to this answer. Add a check on crontab and reboot if in the wrong time window.

    – Hastur
    Feb 8 at 9:40
















2












2








2








I have a dual boot setup: Manjaro KDE and Elementary OS.



Let's say I'd like to prevent Manjaro KDE from booting at a certain time (for example between 8:00 AM - 1:00 PM) so that only Elementary OS can be used in that particular time.



Since I think I can't act at GRUB level, Manjaro must certainly be able to boot but then some piece of software should prevent the user from logging in or making the distro unusable at that particular time.



Is this possible? What could I do?










share|improve this question
















I have a dual boot setup: Manjaro KDE and Elementary OS.



Let's say I'd like to prevent Manjaro KDE from booting at a certain time (for example between 8:00 AM - 1:00 PM) so that only Elementary OS can be used in that particular time.



Since I think I can't act at GRUB level, Manjaro must certainly be able to boot but then some piece of software should prevent the user from logging in or making the distro unusable at that particular time.



Is this possible? What could I do?







linux multi-boot cron manjaro elementaryos






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 8 at 10:33









Mr Shunz

1,92512017




1,92512017










asked Feb 8 at 9:05









RaiNRaiN

132




132








  • 1





    Just an hint: for example you can put a check on the time when you boot in KDE. If it is not passed you can change the boot default option (with zero waiting time) and reboot. Give it a look to this answer. Add a check on crontab and reboot if in the wrong time window.

    – Hastur
    Feb 8 at 9:40
















  • 1





    Just an hint: for example you can put a check on the time when you boot in KDE. If it is not passed you can change the boot default option (with zero waiting time) and reboot. Give it a look to this answer. Add a check on crontab and reboot if in the wrong time window.

    – Hastur
    Feb 8 at 9:40










1




1





Just an hint: for example you can put a check on the time when you boot in KDE. If it is not passed you can change the boot default option (with zero waiting time) and reboot. Give it a look to this answer. Add a check on crontab and reboot if in the wrong time window.

– Hastur
Feb 8 at 9:40







Just an hint: for example you can put a check on the time when you boot in KDE. If it is not passed you can change the boot default option (with zero waiting time) and reboot. Give it a look to this answer. Add a check on crontab and reboot if in the wrong time window.

– Hastur
Feb 8 at 9:40












2 Answers
2






active

oldest

votes


















1














What it seems today it can not seem tomorrow :-).



You should have been allowed to use date and time related commands on /boot/grub/grub.cfg editing /etc/grub.d even if they should rely on the internal PC clock, that has to be protected from users under both OSes and BIOS, as well as the possibility to boot from sources different from those two. Moreover remember that a failure of the motherboard battery may lead to a corrupt time shown by the internal clock.



Give it a look on this ubuntu thread for some more practical hints or to this post for a simple panorama. Hint relays on the datehook module and the config file (/boot/grub/grub.cfg)




insmod datehook
if [ "$HOUR" -ge "8" -a "$HOUR" -lt "13" ]; then set default="0" #Manjaro KDE
else set default="1" #Elementary OS
fi





By hands



If you cannot use the grub features above, you can apply a strategy





  1. to preempt the logging in the wrong time forcing a reboot with a specific selection as described in these other answers. You should put a time check in a script that has to be executed on boot. If the check is not passed you should force a reboot with a different grub option.

    Main steps are:




    • in the /etc/default/grub write/check GRUB_DEFAULT=saved

    • Use grub-set-default(if you want) for the willed boot option


    • sudo update-grub to save it


    In the script to be run





    • grub-reboot <entry> with that points to the other OS.



  2. kicking out the people still logged in when it will arrive a black time window, e.g. following the suggestion of davidgo adding a check in the crontab (but again I think it is better to write a little script that reboots with the willed grub option or if it works directly grub-reboot <entry>).



Have a nice reading and trying time...






share|improve this answer

































    2














    If you can put a solytion in place for this, you can bypass it. If its to frustrate attempts by someone less knowledgeable, you can simply add a line to crontab to reboot every minute between those hours. Possibly along the lines of editing /etc/crontab and adding



           * 8-12 * * * root shutdown -h now





    share|improve this answer
























    • If you want/find useful you can give a look to the comment above (mainly the link) about how to change the grub behavior to minimize the rebooting.

      – Hastur
      Feb 8 at 9:44











    • BTW I love the approach "to frustrate the attempts of someone less expert" ... or they increase their knowledge or they have to be bored to death! :-)

      – Hastur
      Feb 8 at 10:49












    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',
    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%2fsuperuser.com%2fquestions%2f1403456%2fhow-can-i-prevent-myself-from-booting-a-certain-distro-in-some-particular-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









    1














    What it seems today it can not seem tomorrow :-).



    You should have been allowed to use date and time related commands on /boot/grub/grub.cfg editing /etc/grub.d even if they should rely on the internal PC clock, that has to be protected from users under both OSes and BIOS, as well as the possibility to boot from sources different from those two. Moreover remember that a failure of the motherboard battery may lead to a corrupt time shown by the internal clock.



    Give it a look on this ubuntu thread for some more practical hints or to this post for a simple panorama. Hint relays on the datehook module and the config file (/boot/grub/grub.cfg)




    insmod datehook
    if [ "$HOUR" -ge "8" -a "$HOUR" -lt "13" ]; then set default="0" #Manjaro KDE
    else set default="1" #Elementary OS
    fi





    By hands



    If you cannot use the grub features above, you can apply a strategy





    1. to preempt the logging in the wrong time forcing a reboot with a specific selection as described in these other answers. You should put a time check in a script that has to be executed on boot. If the check is not passed you should force a reboot with a different grub option.

      Main steps are:




      • in the /etc/default/grub write/check GRUB_DEFAULT=saved

      • Use grub-set-default(if you want) for the willed boot option


      • sudo update-grub to save it


      In the script to be run





      • grub-reboot <entry> with that points to the other OS.



    2. kicking out the people still logged in when it will arrive a black time window, e.g. following the suggestion of davidgo adding a check in the crontab (but again I think it is better to write a little script that reboots with the willed grub option or if it works directly grub-reboot <entry>).



    Have a nice reading and trying time...






    share|improve this answer






























      1














      What it seems today it can not seem tomorrow :-).



      You should have been allowed to use date and time related commands on /boot/grub/grub.cfg editing /etc/grub.d even if they should rely on the internal PC clock, that has to be protected from users under both OSes and BIOS, as well as the possibility to boot from sources different from those two. Moreover remember that a failure of the motherboard battery may lead to a corrupt time shown by the internal clock.



      Give it a look on this ubuntu thread for some more practical hints or to this post for a simple panorama. Hint relays on the datehook module and the config file (/boot/grub/grub.cfg)




      insmod datehook
      if [ "$HOUR" -ge "8" -a "$HOUR" -lt "13" ]; then set default="0" #Manjaro KDE
      else set default="1" #Elementary OS
      fi





      By hands



      If you cannot use the grub features above, you can apply a strategy





      1. to preempt the logging in the wrong time forcing a reboot with a specific selection as described in these other answers. You should put a time check in a script that has to be executed on boot. If the check is not passed you should force a reboot with a different grub option.

        Main steps are:




        • in the /etc/default/grub write/check GRUB_DEFAULT=saved

        • Use grub-set-default(if you want) for the willed boot option


        • sudo update-grub to save it


        In the script to be run





        • grub-reboot <entry> with that points to the other OS.



      2. kicking out the people still logged in when it will arrive a black time window, e.g. following the suggestion of davidgo adding a check in the crontab (but again I think it is better to write a little script that reboots with the willed grub option or if it works directly grub-reboot <entry>).



      Have a nice reading and trying time...






      share|improve this answer




























        1












        1








        1







        What it seems today it can not seem tomorrow :-).



        You should have been allowed to use date and time related commands on /boot/grub/grub.cfg editing /etc/grub.d even if they should rely on the internal PC clock, that has to be protected from users under both OSes and BIOS, as well as the possibility to boot from sources different from those two. Moreover remember that a failure of the motherboard battery may lead to a corrupt time shown by the internal clock.



        Give it a look on this ubuntu thread for some more practical hints or to this post for a simple panorama. Hint relays on the datehook module and the config file (/boot/grub/grub.cfg)




        insmod datehook
        if [ "$HOUR" -ge "8" -a "$HOUR" -lt "13" ]; then set default="0" #Manjaro KDE
        else set default="1" #Elementary OS
        fi





        By hands



        If you cannot use the grub features above, you can apply a strategy





        1. to preempt the logging in the wrong time forcing a reboot with a specific selection as described in these other answers. You should put a time check in a script that has to be executed on boot. If the check is not passed you should force a reboot with a different grub option.

          Main steps are:




          • in the /etc/default/grub write/check GRUB_DEFAULT=saved

          • Use grub-set-default(if you want) for the willed boot option


          • sudo update-grub to save it


          In the script to be run





          • grub-reboot <entry> with that points to the other OS.



        2. kicking out the people still logged in when it will arrive a black time window, e.g. following the suggestion of davidgo adding a check in the crontab (but again I think it is better to write a little script that reboots with the willed grub option or if it works directly grub-reboot <entry>).



        Have a nice reading and trying time...






        share|improve this answer















        What it seems today it can not seem tomorrow :-).



        You should have been allowed to use date and time related commands on /boot/grub/grub.cfg editing /etc/grub.d even if they should rely on the internal PC clock, that has to be protected from users under both OSes and BIOS, as well as the possibility to boot from sources different from those two. Moreover remember that a failure of the motherboard battery may lead to a corrupt time shown by the internal clock.



        Give it a look on this ubuntu thread for some more practical hints or to this post for a simple panorama. Hint relays on the datehook module and the config file (/boot/grub/grub.cfg)




        insmod datehook
        if [ "$HOUR" -ge "8" -a "$HOUR" -lt "13" ]; then set default="0" #Manjaro KDE
        else set default="1" #Elementary OS
        fi





        By hands



        If you cannot use the grub features above, you can apply a strategy





        1. to preempt the logging in the wrong time forcing a reboot with a specific selection as described in these other answers. You should put a time check in a script that has to be executed on boot. If the check is not passed you should force a reboot with a different grub option.

          Main steps are:




          • in the /etc/default/grub write/check GRUB_DEFAULT=saved

          • Use grub-set-default(if you want) for the willed boot option


          • sudo update-grub to save it


          In the script to be run





          • grub-reboot <entry> with that points to the other OS.



        2. kicking out the people still logged in when it will arrive a black time window, e.g. following the suggestion of davidgo adding a check in the crontab (but again I think it is better to write a little script that reboots with the willed grub option or if it works directly grub-reboot <entry>).



        Have a nice reading and trying time...







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 8 at 10:38

























        answered Feb 8 at 9:54









        HasturHastur

        14k53368




        14k53368

























            2














            If you can put a solytion in place for this, you can bypass it. If its to frustrate attempts by someone less knowledgeable, you can simply add a line to crontab to reboot every minute between those hours. Possibly along the lines of editing /etc/crontab and adding



                   * 8-12 * * * root shutdown -h now





            share|improve this answer
























            • If you want/find useful you can give a look to the comment above (mainly the link) about how to change the grub behavior to minimize the rebooting.

              – Hastur
              Feb 8 at 9:44











            • BTW I love the approach "to frustrate the attempts of someone less expert" ... or they increase their knowledge or they have to be bored to death! :-)

              – Hastur
              Feb 8 at 10:49
















            2














            If you can put a solytion in place for this, you can bypass it. If its to frustrate attempts by someone less knowledgeable, you can simply add a line to crontab to reboot every minute between those hours. Possibly along the lines of editing /etc/crontab and adding



                   * 8-12 * * * root shutdown -h now





            share|improve this answer
























            • If you want/find useful you can give a look to the comment above (mainly the link) about how to change the grub behavior to minimize the rebooting.

              – Hastur
              Feb 8 at 9:44











            • BTW I love the approach "to frustrate the attempts of someone less expert" ... or they increase their knowledge or they have to be bored to death! :-)

              – Hastur
              Feb 8 at 10:49














            2












            2








            2







            If you can put a solytion in place for this, you can bypass it. If its to frustrate attempts by someone less knowledgeable, you can simply add a line to crontab to reboot every minute between those hours. Possibly along the lines of editing /etc/crontab and adding



                   * 8-12 * * * root shutdown -h now





            share|improve this answer













            If you can put a solytion in place for this, you can bypass it. If its to frustrate attempts by someone less knowledgeable, you can simply add a line to crontab to reboot every minute between those hours. Possibly along the lines of editing /etc/crontab and adding



                   * 8-12 * * * root shutdown -h now






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 8 at 9:40









            davidgodavidgo

            45k75392




            45k75392













            • If you want/find useful you can give a look to the comment above (mainly the link) about how to change the grub behavior to minimize the rebooting.

              – Hastur
              Feb 8 at 9:44











            • BTW I love the approach "to frustrate the attempts of someone less expert" ... or they increase their knowledge or they have to be bored to death! :-)

              – Hastur
              Feb 8 at 10:49



















            • If you want/find useful you can give a look to the comment above (mainly the link) about how to change the grub behavior to minimize the rebooting.

              – Hastur
              Feb 8 at 9:44











            • BTW I love the approach "to frustrate the attempts of someone less expert" ... or they increase their knowledge or they have to be bored to death! :-)

              – Hastur
              Feb 8 at 10:49

















            If you want/find useful you can give a look to the comment above (mainly the link) about how to change the grub behavior to minimize the rebooting.

            – Hastur
            Feb 8 at 9:44





            If you want/find useful you can give a look to the comment above (mainly the link) about how to change the grub behavior to minimize the rebooting.

            – Hastur
            Feb 8 at 9:44













            BTW I love the approach "to frustrate the attempts of someone less expert" ... or they increase their knowledge or they have to be bored to death! :-)

            – Hastur
            Feb 8 at 10:49





            BTW I love the approach "to frustrate the attempts of someone less expert" ... or they increase their knowledge or they have to be bored to death! :-)

            – Hastur
            Feb 8 at 10:49


















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1403456%2fhow-can-i-prevent-myself-from-booting-a-certain-distro-in-some-particular-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

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

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

            IC on Digikey is 5x more expensive than board containing same IC on Alibaba: How? [on hold]