telinit 1 and run a command therewhy do I have two different results if I run a program through terminal(as...

Why is the voltage measurement of this circuit different when the switch is on?

Can ADFS connect to other SSO services?

Sci fi short story, robot city that nags people about health

Should developer taking test phones home or put in office?

Is there a maximum distance from a planet that a moon can orbit?

Folding basket - is there such a thing?

Is my Rep in Stack-Exchange Form?

Why aren't cotton tents more popular?

How long would it take to cross the Channel in 1890's?

How risky is real estate?

Interaction between Leyline of Anticipation and Teferi, Time Raveler

What was the Shuttle Carrier Aircraft escape tunnel?

Does this Wild Magic result affect the sorcerer or just other creatures?

Fill NAs in R with zero if the next valid data point is more than 2 intervals away

3D Crossword, Cryptic, Statue View & Maze

Why do some professors with PhDs leave their professorships to teach high school?

Underbar nabla symbol doesn't work

Is it possible writing coservation of relativistic energy in this naive way?

How does metta sutra develop loving kindness

Can we put equal sign after aggregate functions in sql?

Why do textbooks often include the solutions to odd or even numbered problems but not both?

How can I politely work my way around not liking coffee or beer when it comes to professional networking?

expiry or manufactured date?

Why doesn't a marching band have strings?



telinit 1 and run a command there


why do I have two different results if I run a program through terminal(as root) or /etc/init.d(or /etc/rc.local)Caps lock doesn't take effect on all lettersIssues executing programdebian wheezy extreme boot delayRSync Error in scriptProcesses blocking on shutdownroot password not working when entering in Single-User ModeApper errors and looking strange when opening it via sudosystemd root authentication every new shell sessionHow to run script at start when everything is up and running?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I need to do some maintenance on a bunch of Debian (Wheezy) systems, and it has to happen at run level 1. But not all machines have a keyboard and a screen; some are even located somewhere else. So I can't just go there and type in the root password to trigger the job.



So my question is how can I tell Debian to run a command right before the "Type root password or ^D" prompt?



I've tried to make a init script that only runs on run level 1, but still it was triggered before all processes where killed.



Is there a way to do this?










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.
















  • Why does it need to be done on runlevel 1?

    – jordanm
    Jul 15 '14 at 15:11






  • 1





    I need to remount the root filesystem as ro

    – Florian Fida
    Jul 15 '14 at 17:36


















0















I need to do some maintenance on a bunch of Debian (Wheezy) systems, and it has to happen at run level 1. But not all machines have a keyboard and a screen; some are even located somewhere else. So I can't just go there and type in the root password to trigger the job.



So my question is how can I tell Debian to run a command right before the "Type root password or ^D" prompt?



I've tried to make a init script that only runs on run level 1, but still it was triggered before all processes where killed.



Is there a way to do this?










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.
















  • Why does it need to be done on runlevel 1?

    – jordanm
    Jul 15 '14 at 15:11






  • 1





    I need to remount the root filesystem as ro

    – Florian Fida
    Jul 15 '14 at 17:36














0












0








0


1






I need to do some maintenance on a bunch of Debian (Wheezy) systems, and it has to happen at run level 1. But not all machines have a keyboard and a screen; some are even located somewhere else. So I can't just go there and type in the root password to trigger the job.



So my question is how can I tell Debian to run a command right before the "Type root password or ^D" prompt?



I've tried to make a init script that only runs on run level 1, but still it was triggered before all processes where killed.



Is there a way to do this?










share|improve this question
















I need to do some maintenance on a bunch of Debian (Wheezy) systems, and it has to happen at run level 1. But not all machines have a keyboard and a screen; some are even located somewhere else. So I can't just go there and type in the root password to trigger the job.



So my question is how can I tell Debian to run a command right before the "Type root password or ^D" prompt?



I've tried to make a init script that only runs on run level 1, but still it was triggered before all processes where killed.



Is there a way to do this?







debian administration runlevel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 15 '14 at 15:13









Christopher

11.4k4 gold badges33 silver badges51 bronze badges




11.4k4 gold badges33 silver badges51 bronze badges










asked Jul 15 '14 at 14:53









Florian FidaFlorian Fida

9896 silver badges9 bronze badges




9896 silver badges9 bronze badges





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.















  • Why does it need to be done on runlevel 1?

    – jordanm
    Jul 15 '14 at 15:11






  • 1





    I need to remount the root filesystem as ro

    – Florian Fida
    Jul 15 '14 at 17:36



















  • Why does it need to be done on runlevel 1?

    – jordanm
    Jul 15 '14 at 15:11






  • 1





    I need to remount the root filesystem as ro

    – Florian Fida
    Jul 15 '14 at 17:36

















Why does it need to be done on runlevel 1?

– jordanm
Jul 15 '14 at 15:11





Why does it need to be done on runlevel 1?

– jordanm
Jul 15 '14 at 15:11




1




1





I need to remount the root filesystem as ro

– Florian Fida
Jul 15 '14 at 17:36





I need to remount the root filesystem as ro

– Florian Fida
Jul 15 '14 at 17:36










1 Answer
1






active

oldest

votes


















0














I found a way, but it feels dirty... :)

So i'll leave this open and see if someone has a clean way.



My solution is to modify inittab to run a script instead of sulogin and restore the old inittab from within the script.



here is a 'cut and paste to the terminal' proof of concept version which i just used to compact some VM harddrives.



But: Don't just try this unless you know what it does!



mkdir -p /opt/single
cp -a /etc/inittab /opt/single/inittab
sed -i "s//sbin/sulogin//opt/single/job.sh/" /etc/inittab
cat>/opt/single/job.sh<<EOF
#!/bin/bash
#restore inittab
mv -fv /opt/single/inittab /etc/inittab
#make sure no one runs this by accident
chmod -x /opt/single/job.sh
#do your thing...
mount -o remount,ro /dev/sda1
fsck.ext4 -vfp /dev/sda1
zerofree -v /dev/sda1
mount -o remount,rw /dev/sda1
#work done
reboot
EOF
chmod +x /opt/single/job.sh
telinit 1





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%2f144655%2ftelinit-1-and-run-a-command-there%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














    I found a way, but it feels dirty... :)

    So i'll leave this open and see if someone has a clean way.



    My solution is to modify inittab to run a script instead of sulogin and restore the old inittab from within the script.



    here is a 'cut and paste to the terminal' proof of concept version which i just used to compact some VM harddrives.



    But: Don't just try this unless you know what it does!



    mkdir -p /opt/single
    cp -a /etc/inittab /opt/single/inittab
    sed -i "s//sbin/sulogin//opt/single/job.sh/" /etc/inittab
    cat>/opt/single/job.sh<<EOF
    #!/bin/bash
    #restore inittab
    mv -fv /opt/single/inittab /etc/inittab
    #make sure no one runs this by accident
    chmod -x /opt/single/job.sh
    #do your thing...
    mount -o remount,ro /dev/sda1
    fsck.ext4 -vfp /dev/sda1
    zerofree -v /dev/sda1
    mount -o remount,rw /dev/sda1
    #work done
    reboot
    EOF
    chmod +x /opt/single/job.sh
    telinit 1





    share|improve this answer




























      0














      I found a way, but it feels dirty... :)

      So i'll leave this open and see if someone has a clean way.



      My solution is to modify inittab to run a script instead of sulogin and restore the old inittab from within the script.



      here is a 'cut and paste to the terminal' proof of concept version which i just used to compact some VM harddrives.



      But: Don't just try this unless you know what it does!



      mkdir -p /opt/single
      cp -a /etc/inittab /opt/single/inittab
      sed -i "s//sbin/sulogin//opt/single/job.sh/" /etc/inittab
      cat>/opt/single/job.sh<<EOF
      #!/bin/bash
      #restore inittab
      mv -fv /opt/single/inittab /etc/inittab
      #make sure no one runs this by accident
      chmod -x /opt/single/job.sh
      #do your thing...
      mount -o remount,ro /dev/sda1
      fsck.ext4 -vfp /dev/sda1
      zerofree -v /dev/sda1
      mount -o remount,rw /dev/sda1
      #work done
      reboot
      EOF
      chmod +x /opt/single/job.sh
      telinit 1





      share|improve this answer


























        0












        0








        0







        I found a way, but it feels dirty... :)

        So i'll leave this open and see if someone has a clean way.



        My solution is to modify inittab to run a script instead of sulogin and restore the old inittab from within the script.



        here is a 'cut and paste to the terminal' proof of concept version which i just used to compact some VM harddrives.



        But: Don't just try this unless you know what it does!



        mkdir -p /opt/single
        cp -a /etc/inittab /opt/single/inittab
        sed -i "s//sbin/sulogin//opt/single/job.sh/" /etc/inittab
        cat>/opt/single/job.sh<<EOF
        #!/bin/bash
        #restore inittab
        mv -fv /opt/single/inittab /etc/inittab
        #make sure no one runs this by accident
        chmod -x /opt/single/job.sh
        #do your thing...
        mount -o remount,ro /dev/sda1
        fsck.ext4 -vfp /dev/sda1
        zerofree -v /dev/sda1
        mount -o remount,rw /dev/sda1
        #work done
        reboot
        EOF
        chmod +x /opt/single/job.sh
        telinit 1





        share|improve this answer













        I found a way, but it feels dirty... :)

        So i'll leave this open and see if someone has a clean way.



        My solution is to modify inittab to run a script instead of sulogin and restore the old inittab from within the script.



        here is a 'cut and paste to the terminal' proof of concept version which i just used to compact some VM harddrives.



        But: Don't just try this unless you know what it does!



        mkdir -p /opt/single
        cp -a /etc/inittab /opt/single/inittab
        sed -i "s//sbin/sulogin//opt/single/job.sh/" /etc/inittab
        cat>/opt/single/job.sh<<EOF
        #!/bin/bash
        #restore inittab
        mv -fv /opt/single/inittab /etc/inittab
        #make sure no one runs this by accident
        chmod -x /opt/single/job.sh
        #do your thing...
        mount -o remount,ro /dev/sda1
        fsck.ext4 -vfp /dev/sda1
        zerofree -v /dev/sda1
        mount -o remount,rw /dev/sda1
        #work done
        reboot
        EOF
        chmod +x /opt/single/job.sh
        telinit 1






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 16 '14 at 2:56









        Florian FidaFlorian Fida

        9896 silver badges9 bronze badges




        9896 silver badges9 bronze badges






























            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%2f144655%2ftelinit-1-and-run-a-command-there%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

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...