4 ms·
Redirect a running process output to a file and log out
- ryandotsmith 16y agoIs this better than running the program in something like screen or tmux?
- angusgr 16y agoI get the impression that this is for when you've forgotten to set up something like screen beforehand.
- paulitex 16y agoExplained with comments: https://gist.github.com/782312 https://gist.github.com/782312 (edit: made clearer).
- zaius 16y agoNice. Thanks for that. The only addendum I would make is that the second parameter to open specifies to open the file as writable. Usually the constant is O_WRONLY, but it wasn't working for me in GDB.
- julian37 16y agoSomeone has rolled this into a script: http://www.isi.edu/~yuri/dupx/ http://www.isi.edu/~yuri/dupx/
- sliverstorm 16y agoWow, I get that the gdb stuff is the real clever trickery, but 'disown' is the most valuable thing I got from that. I knew about nohup, but I didn't know about disown.
- zaius 16y agoDisown is actually implemented by bash (or your shell of choice). From my understanding, it just stops the HUP propagating down to that child. There might be a more shell-agnostic way to assign the parent process id too.
- fendrak 16y agoAlternatively, if you know you're going to want to do this beforehand, check out the 'nohup' command. It does basically the same thing with any command it's given. http://en.wikipedia.org/wiki/Nohup http://en.wikipedia.org/wiki/Nohup
- gbrindisi 16y agoAm I a bad person for using nohup and stderr/stdout redirect? Anyway this is a really nice creative alternative.
- lysium 16y agoActually, it's not meant as an alternative, but when you forgot to use nohup or stderr/stdout redirect, ie. redirect output from an already running process.
- hjkdfgeg 16y ago====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== Gold autumn, personality Mes clothing + Shoes, Travel bag that grabs an eye coat + Chao packet Free transport ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )==== ====== ( http://u.ly/73I http://u.ly/73I )====