4 ms·
> I failed to grasp what it is It queues up Unix (shell) jobs. Do you understand what's meant by a shell "job"? Like "cmd &"? Typing "cmd1 &", "cmd2 &", etc
by jbotz 6y ago
> I failed to grasp what it is
It queues up Unix (shell) jobs. Do you understand what's meant by a shell "job"? Like "cmd &"?
Typing "cmd1 &", "cmd2 &", etc, runs jobs in parallel. "nq cmd1", "nq cmd2", runs them serially, in a queue.
- hnarn 6y agoHow is it in practice different to something like: cmd && cmd2 & edit: From reading other comments I guess the difference is not mainly that it keeps running if the shell dies but that it allows you to easily append new stuff to the end of the queue
- aflag 6y agoAlso, if cmd fails, I believe it will execut cmd2. It also redirect the output of each command to a different file.
- hnarn 6y agoSure, but executing cmd2 even if cmd1 fails is done with ;
- aflag 6y agoUsing ; will not work if you ran set -e before (eg.: if you're using it in a script). Perhaps more importantly, cmd1; cmd2 & will not work either, you'll need a subshell. So, you need at least: ( set +e; cmd1 ; cmd2 ) &. And there are probably other caveats. And we haven't even got to the output redirection yet.