Command Line Utilities {#commandline}

Linux {#linux}

Java

Containers, K8s, Cloud

Liferay

Miscellaneous

Remove all messages from exim queue:

exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash

OR

exim -bp | exiqgrep -i | xargs exim -Mrm

Replace ^M (0x0D) in file

sed -i 's/\r//' tomcat/conf/server.xml

HTTP readiness check with curl. This one is for Elasticsearch availability

#!/bin/bash

while [ true ]; do
  ES_STATUS="$(curl -s -w '%{http_code}' --insecure --connect-timeout 5 --max-time 10 -o /dev/null --noproxy '*' 'http://10.10.11.1:9200/_cluster/health?wait_for_status=green&timeout=5s')";
  if [ $ES_STATUS -eq "200" ]
  then
      break;
  fi

  echo 'waiting for elasticsearch';
  sleep 5;
done;

Password generation with simple shell commands

< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-16};echo;

Pretty print json:

python3 -m json.tool file.json

In Python 3.5+ the JSON object is no longer sorted by default. To sort, add the --sort-keys flag to the end. python3 -m json.tool --sort-keys

Force ssh password auth:

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no