4 ms·
Having skimmed the README, I failed to grasp what it is. I would appreciate it if the README featured a clear one-sentence summary of what the tool does. Like..
by andrey_utkin 6y ago
Having skimmed the README, I failed to grasp what it is. I would appreciate it if the README featured a clear one-sentence summary of what the tool does. Like...
> cat - concatenate files and print on the standard output
> nohup - run a command immune to hangups, with output to a non-tty
> at — execute commands at a later time
Anyway, it's good to see new conceptual tools being developed for the Unix Toolbox, keep up!
- deleted 6y ago[deleted]
- jolmg 6y agoI think the first example is pretty good: > Build targets clean, depends, all, without occupying the terminal This accommodates a workflow where one wouldn't prefer to just open up another terminal to do other stuff (maybe you're not in a graphical environment, maybe there's no tmux, etc.). With just the shell features, one could do `make ... && make ... && make ... &`, but that would cause bothersome output that would prevent you from effectively working in the same terminal. One could redirect the output of those commands, but then you lose it, or you have to think of where to collect it. This provides an alternative where you can background and still have convenient access to the output when you need it. The other use is something like: $ nq mpv $youtube_url $ #work... work... work.... $ nq mpv $next_youtube_url so that the next starts when the first finishes.
- Zhyl 6y agoThe mpv example was my main thought. If you want to add something to a playlist using mpv's playlist feature you have to stop and restart mpv.
- jolmg 6y agoDoesn't help if you like to loop the playlist, though.
- JNRowe 6y agoIt probably isn't as user friendly as you'd want, but you can reload the playlist by firing commands at a socket. See the "JSON IPC" section in the mpv man page, and specifically the load* commands. jo¹ and socat² are probably the simplest way to use it if you're not looking for heavy scripting. The scriptability of mpv is really nice if you're the sort of person who likes building your perfect environment, and also a huge pit of addictive time sinks. </warning> ¹ https://github.com/jpmens/jo https://github.com/jpmens/jo ² http://www.dest-unreach.org/socat/ http://www.dest-unreach.org/socat/
- waynesonfire 6y agoIt also offers a better history UX. For example, if you issued, make .. && make foobar && make .. and you wanted to just run 'make foobar' again you'd search your history for the last foobar invocation, and be required to do some editing. With nq this wouldn't be necessary. It's also not clear to me if nq has '&&' or ';' semantics in the event a command fails. I suspect it's ';'. Clever and fun tool but unlikely I'll adopt it.
- epistasis 6y ago"Lightweight job queue system" is in the first line of the README. I'm struggling to come up with any sort of better description than that. Some attempts: * shell-controllable queue of commands * queue for running commands one after another but I still think the README's is the best.
- aflag 6y ago"Lightweight" adds nothing to the description and "job" is ambiguous. I think "nq - queues the execution of background processes" would be a better description.
- umvi 6y agoYou queue up terminal commands to be run in the background so that you can continue doing other things in the meantime.
- ww520 6y agoFrom the reading of the text, it’s a serialized job queue for arbitrary commands submitted from the command line. It’s the equivalent of “cmd1 & cmd2 & cmd3” except all are put to the background and will be run serially one after another. And new command is automatically added to the end.
- monadic3 6y agoHow do you even describe what a job queue does in once sentence? I don't think your standard is possible for most unix commands, let alone most software. "sed -- stream editor" is, frankly, a useless description.
- blablabla123 6y agoThe README is really not ideal and not reflecting how orthogonal/concise the tool is. Obviously it's a queue and it's as simple as `nq cmd`. Also one can see the status with `fq`
- gigatexal 6y agoat looks cool. https://linux.die.net/man/1/at https://linux.die.net/man/1/at
- 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.
- bigiain 6y ago> nq -- add a command to a queue that executes each command in the background strictly in the order they were added.
- Nukesor 6y agoI actually wrote a more modern solution to `nq` named Pueue. (https://github.com/Nukesor/pueue https://github.com/Nukesor/pueue) There are a lot of examples and a FAQ section + a Wiki, if you're interested in more information why one might need such a tool.