Bash: Find out the exit codes of all piped commands
Bash stores the exitcodestatus of piped commands in the environment variable PIPESTATUS
So you can just echo ${PIPESTATUS[@]}
to get them all.
13:52:30 ✔ claus:~$ ps ax | grep /usr/bin/ruby
13205 pts/20 S+ 0:00 grep --color=auto /usr/bin/ruby
13:52:43 ✔ claus:~$ echo ${PIPESTATUS[@]}
0 0
PIPESTATUS
is an array, so you can get the exitcode of an specific command (first pipe):
13:54:20 ✔ claus:~$ echo ${PIPESTATUS[1]}
0
Related cards:
Useful PostgreSQL commands
on the bash (issued as postgres user)
Start/Stop/Restart PostgreSQL
pg_ctl -D $configdir start|stop|restart
Start/Stop/Restart the corresponding PostgreSQL using the given configuration directory. The configuration directory sh...
HowTo: Rebalance Elasticsearch Shards
If you end up with an Elasticsearch cluster which has a very different disk usage on it's nodes you can use these steps to rebalance the shards.
Before we begin it's important to understand how Elasticsearch defines [balance](https://www.elastic....
Terraform/Terragrunt: Hide Refreshing State..., Reading..., Read complete after... output
Terraform (and terragrunt) gives a lot of output when running plan
or apply
, outputting a lot of progress information when refreshing the state before creating the plan. [They have reasons for this but it doesn't look like there is going to be...
FAQ for When PostgreSQL Indexes Are Corrupted After Locale Changes
When changing glibc versions, it's possible to end up with corrupt indexes in PostgreSQL.
Are My Indexes Affected?
If your database has...
Find unmaintained packages with apt-forktracer
If you use third party APT sources you might end up with unmaintained packages after removing the external source or performing a dist-upgrade. The reason for this is how external sources overwrite official package versions.
[apt-forktracer
](ht...
manual haproxy backend failover
If you want to perform a failover on another haproxy backend server this is the way you should do it:
Gather information
Via hatop
Note: Please mind that the names of frontends / backends / servers are only examples. Mind this when yo...
netfilter's Connection Tracking system (nf_conntrack)
What is netfilter's Connection Tracking system?
The connection tracking system often referenced as nf_conntrack
is part of the Netfilter framework. It allows the ...
HowTo: Curl applications that are usually behind reverse proxies with TLS termination without the application redirecting to https schema
A lot of web applications require being called over https
, which is a good thing. It's possible to configure this requirement at the web- or proxy server level, where nginx
or apache
will just redirect every request on http
to https
. Som...
Useful jq commands
jq
is great when dealing with JSON data. Check out the official jq Manual.
Content
- Select only specific keys
- Modify keys
- [Set default v...
Lenovo Laptop BIOS Update with Linux
You will need to look here and find your own device. Look for the "bootable CD" download, which will give you an ISO file.
Then you need a Perl script from the interne...