// you’re reading...

Asides

My favority BASH one-liners

Let me preface this post by saying, these are hacks. Neither the best or the only ways to achieve the desired results. But hey, if they work for me, they may work for you. Enjoy!

ping -i 10 4.2.2.2

Send a ping request to an IP address once every 10 seconds. Why would I do this? I’ve noticed that on some wifi connections, I disconnected after so many minutes of inactivity. This keeps my connection active when I’m not.

for i in {1..25}; do mysql -u user -ppassword -h some-load-balancer-vip -e "SELECT @@hostname" -s ; done

Ask mysqld 25 times what host name it’s running for a particular hostname (-h). Why would I do this? If you’re calling a real host, then it’s not much fun… however, against a Load Balancer VIP, that’s another story. It’s a down and dirty way to check which hosts are members of a Load Balancer VIP and to see if the balance method is behaving as expected. e.g. if you have 3 mysqld hosts behind a VIP, you should expect to see at least 3 different host names depending on the balance algorithm of the LB.

sar -i 1 10

For ten seconds, show system activity every second.

echo "722 / 846" | bc -l

Use the “bc” command for basic calculations! Or just:

echo $((722 / 846));

Do some math in your shell.

echo -n "HashMe" | shasum -a 1

The shasum command is a hash one-stop shop.

Discussion

No comments for “My favority BASH one-liners”

Post a comment

Help support my site and buy a domain name at http://domainsemailhosting.com/

%d bloggers like this: