I am doing quite a lot of work inside tmux. I especially love that I can start multiple windows/panes and use them to run the same thing across multiple servers, while still having normal shell access between steps.
This thing was greatly improved when I wrote tmux_send_to_many, but one thing was missing – waiting for the thing, running in tmux window to end.
Generally, I had to look at all the windows, and decide when to launch next step on my own.
Continue reading Wait for program(s) in tmux panes to end…
I wrote previously about tmux_send_to_many and group_by shell tools that I authored.
Since then I got some more ideas for changes, and for new tool, so figured I'll make an honest git repo for it. Repo is on GitLab, and all the tools inside can be freely used.
While I was doing it, I fixed some things in tmux_send_to_many.
And then – I remembered that for long time I was missing “visual-sleep" type of tool. One that will show some progress information while it's working.
Continue reading visual sleep in shell, and shell_utils repo information
I assume that everyone reading my blog understands GROUP BY clause in SQL.
Lately I've been doing some maintenance work, and found myself in a position that I could really use similar thing in shell.
Continue reading Grouping values in shell
Tmux is terminal multiplexer. Kinda like old screen, but with much more functionality.
When I work on my servers, it's pretty common that I have to do the same things to multiple servers. To make my life easier I start tmux, and in there start many “windows", each related to work on single server.
I name the windows in a way that let's me quickly find them, without false positives.
For example, if I'd have to upgrade servers db1..db5 then I'd create windows “up-db1" .. “up-db5", and each window would work on single server.
This is already scriptable – let's assume I'd want to show uptime in all of the windows, I can:
tmux lsw -F '#W' | grep -E '^up-db[0-9]+$' | xargs -r -d$'\n' -I% tmux send-keys -t % uptime Enter
But this gets tedious fast.
Continue reading Automation for doing stuff in multiple windows in tmux
I usually write about PostgreSQL, but lately someone asked for help, and one of the problems was similar to sudo command from title.
This was not the first time I saw it, so figured, I'll write a blogpost about it, just so I can refer people to it in the future.
Continue reading Why does “sudo ls -l /proc/1/fd/*" fail?
On 27th of February, Heikki Linnakangas committed patch:
Add support for piping COPY to/from an external program.
This includes backend "COPY TO/FROM PROGRAM '...'" syntax, and corresponding
psql \copy syntax. Like with reading/writing files, the backend version is
superuser-only, and in the psql version, the program is run in the client.
In the passing, the psql \copy STDIN/STDOUT syntax is subtly changed: if you
the stdin/stdout is quoted, it's now interpreted as a filename. For example,
"\copy foo from 'stdin'" now reads from a file called 'stdin', not from
standard input. Before this, there was no way to specify a filename called
stdin, stdout, pstdin or pstdout.
This creates a new function in pgport, wait_result_to_str(), which can
be used to convert the exit status of a process, as returned by wait(3),
to a human-readable string.
Etsuro Fujita, reviewed by Amit Kapila.
Continue reading Waiting for 9.3 – Add support for piping COPY to/from an external program.
For those of you that don't know – Tmux is program similar to screen, but written from scratch, with different functionality, approach, and capabilities.
I would like to show one particular case where I found that Tmux does something that screen doesn't.
Continue reading Why I like tmux?
(disclaimer: all the data and examples in here are on Linux – the same data can be probably obtained on other systems too, it's just that I work on Linux and don't know other systems well).
This question pops occasionally in various places – PostgreSQL is using too much memory, why is that, and how can it be mitigated?
Before we can go to “optimizing", we should understand the problem. But do we? Both standard tools – ps and top – lie. How/why? Let's see.
Continue reading How much RAM is PostgreSQL using?
I'm quite often doing stuff on remote machines, and quite frequently I start some long-running job, when I remember that I didn't ran it via screen – so it will break, if my network connection will die.
Is there any sane way to start screen automatically? YES.
Continue reading Tips N' Tricks – using GNU Screen as shell
I had this interesting case at work. We have imports of objects. Each object in import file has its “ID" (which can be any string). Same “ID" is in database.
So the idea is pretty simple – we can/should check how many of IDs from import were in database. Unfortunately – we'd rather not really do the comparison in DB, as it is pretty loaded.
Continue reading Set operations in shell