ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    nohup

    Scheduled Pinned Locked Moved IT Discussion
    nohuplinuxshellbash
    6 Posts 5 Posters 980 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Emad RE
      Emad R
      last edited by Emad R

      I learned this recently πŸ˜•

      apparently there is this command

       nohup command-with-options &
      

      Nohup is very helpful when you have to execute a shell-script or command that take a long time to finish. In that case, you don’t want to be connected to the shell and waiting for the command to complete. Instead, execute it with nohup, exit the shell and continue with your other work. Cause it is true I recall I did the background & and it was not reliable I reckon it would exit with your session.

      1 Reply Last reply Reply Quote 2
      • scottalanmillerS
        scottalanmiller
        last edited by

        Yup, I use that easily thirty times a day πŸ™‚ You'll find your output in nohup.out, too.

        1 Reply Last reply Reply Quote 1
        • 1
          1337
          last edited by 1337

          Good reminder @Emad-R !

          I use screen a lot.

          Allows multiple sessions inside one ssh session. And allows you to reconnect to those sessions at a later time. So it can also be used for stuff that takes a long time to complete.

          Usage:

          screen
          

          then do what you want to do, if it takes to long and you cancel the ssh or the ssh session is aborted, then reconnect next time you login with:

          screen -x
          

          Shortcuts:

          • Start another session while working: Ctrl-A + c
          • Switch to first session: Ctrl-A + 0
          • Switch to second session: Ctrl-A + 1
          • Switch to third session: Ctrl-A + 2
          • etc etc

          Man page:
          https://linux.die.net/man/1/screen

          ObsolesceO 1 Reply Last reply Reply Quote 1
          • black3dynamiteB
            black3dynamite
            last edited by

            I'm a big fan of nohup.

            1 Reply Last reply Reply Quote 0
            • ObsolesceO
              Obsolesce @1337
              last edited by

              @Pete-S said in nohup:

              Good reminder @Emad-R !

              I use screen a lot.

              Allows multiple sessions inside one ssh session. And allows you to reconnect to those sessions at a later time. So it can also be used for stuff that takes a long time to complete.

              Usage:

              screen
              

              then do what you want to do, if it takes to long and you cancel the ssh or the ssh session is aborted, then reconnect next time you login with:

              screen -x
              

              Shortcuts:

              • Start another session while working: Ctrl-A + c
              • Switch to first session: Ctrl-A + 0
              • Switch to second session: Ctrl-A + 1
              • Switch to third session: Ctrl-A + 2
              • etc etc

              Man page:
              https://linux.die.net/man/1/screen

              screen is the one I've always used too. I wasn't aware of nohup.

              1 Reply Last reply Reply Quote 0
              • black3dynamiteB
                black3dynamite
                last edited by black3dynamite

                This is what I do when I use nohup.
                I usually create a file with the current pid just in case I need to stop it.

                nohup wget 'https://example.com/fedora.iso' > wget_fedora.log 2>&1 &
                echo $! > wget_fedora_pid.txt
                
                kill -9 `cat wget_fedora_pid.txt`
                rm wget_fedora_pid.txt
                
                1 Reply Last reply Reply Quote 1
                • 1 / 1
                • First post
                  Last post