poll: when you're using your shell **interactively**, do you ever use its job control features (ctrl+z, fg, bg, `jobs`, `wait`, etc?)
(other than maybe occasionally backgrounding a process with &)
poll: when you're using your shell **interactively**, do you ever use its job control features (ctrl+z, fg, bg, `jobs`, `wait`, etc?)
(other than maybe occasionally backgrounding a process with &)
I'm also curious about reasons folks are using job control instead of opening a new tab in their terminal/tmux/screen
so far we have:
* use ctrl+z to suspend a CPU-hungry program because you need to use the CPU for something else
* you're in a situation with no screen/tmux/fancy terminal
* background a GUI app so it's not taking up a terminal tab
* accidentally started a long-running job without tmux/screen
* already set up a lot of environment variables
* accidentally ran ctrl+z
(2/?)
Often: ctrl+z to see what is running on that terminal, exactly. Particularly useful for programs that run over many hours or days.
'screen' is very useful – it's a default for me. But often launched programs are GUI-based in some way, and I need to see with how much RAM I launched them, and what exact parameters.
Even when using screen/tmux, I still need to remember which one is which. And yes I run programs for tens to hundreds of hours, sometimes – to assemble multi-terabyte image volumes from 2D image tiles.
Sometimes it is quicker to ctrl-z out of `vim` and then run `make` and then `fg`.
@b0rk For me, a major factor is a single history, unlike screen/tab.
A secondary reason is knowing that the same terminal is definitely on the right machine (SSH). Yes, screen works, but especially if it's nested, or if you're not 100% sure, Ctrl+Z just feels easier sometimes.
@b0rk Yeah, "start a GUI and retroactively decide I want to background it" is the most common reason I do it.
But then why don't I just open a new terminal?
Well, usually it's because there's some amount of state in the existing one. Activated virtualenv, history that won't be available in a new terminal, variables that are set with API tokens, etc.
Also, I usually have way too many terminals/tabs open at once, avoiding having another one to keep track of helps to avoid further sprawl.
@b0rk ctrl+z
bg
disown
exit
To let a task continue without staying connected. But that also kinda falls under the second option I guess
@b0rk Usually? I've set a load of environment variables as I'm doing something and it's easier to background something that's running and run another command than to remember what I'd set.
It's absolutely a problem of my own making, and if job control didn't exist then I'd keep a dotfile up-to-date, but it does and I don't.
I've had the "no screen/tmux" etc. thing in the past where I'd SSH in somewhere, open an editor to change a config, ctrl+z, restart service, test, etc. - I just found the muscle memory of `ctrl+z, up, up, enter, ctrl+r resta, enter, <test>` loop really easy.
Again, making work for myself, but you know what it's like when you're in the middle of something- the most efficient way of working is whatever you've done a hundred times before.
long-running-command but I want to make it do something after it finishes when I might not be around, so fg && shutdown or similar.@b0rk At my company they don't allow terminal/tmux etc so you have to use bg/nohup/& if you want to start a long running job and be able disconnect your session.
As an aside I've found a way around the tmux ban by compiling a version to run out of my home directory which has been working fairly well.
Ctrl + z and fg occasionally, mostly to suspend a CPU-heavy task for a little while because I need the CPU for something else or want the fans to be silent.Ctrl + z breaks loops (for/while), the current iteration of the loop can be resumed but the next iterations will never run.@b0rk Not only do I often use `jobs`, but I also use the `%` syntax for job numbers a lot. So quite often I'm glad that I wasn't root, because I tried to `kill %1` and mistyped it as `kill 51`.
PID 51 is usually something like a CPU hotplug thread in the kernel, these days.
I haven't done that in a long time, ... because we have windows.
@b0rk I use ctrl-z and fg a lot, especially with vim.
It's so easy to edit some config then ctrl-z and `systemctl restart foobar`.
@xgebi yeah they're a little bit obscure! it's a set of features that let you:
* stop a program and resume it (ctrl+z)
* move a process from running in the foreground to the background
* run multiple programs in the same terminal, see which ones you have running right now, etc
it's a bit weird because these features were invented before we had screen/tmux/terminal emulators with multiple tabs, so some of the problems it solves aren't problems anymore in the same way most of the time