Author:
erics, May 23rd, 2023
In the macOS Terminal, my mouse scroll wheel would magically start scrolling the command line history instead of the window buffer scroll bar on the right to show window history. This happened when an SSH session was disconnected or timed out. The fix is to run the reset command.
Categories: How-To's, Technology Tags: apple, bash, cli, Command line, Disconnect, History, howto, MacOS, Mouse, Scroll, Shell, ssh, Terminal, Timeout, tips
|
No comments
Author:
erics, April 18th, 2022
If you want to preserve quoting to pass shell arguments to a called command, use the four characters “$@” (including the double quotes) instead of the two characters $*
Categories: How-To's, Technology Tags: Argument, Arguments, bash, Command, howto, Keep, Preserve, quote, quotes, Quoting, Save, Shell, tips
|
No comments
Author:
erics, December 11th, 2019
When using Perl’s exec() call, the best way to invoke it is as follows:
|
exec("$dir/myprog.sh",@ARGV); |
This syntax does some important things: – passes a scalar value as the first argument which exec interprets as PROGRAM – passes an array as the second argument which exec will use as the arguments to pass into PROGRAM Note […]
Categories: How-To's, Technology Tags: Arg, Args, Argument, Arguments, bash, Exec, Execute, perl, Program, sh, Shell, System
|
No comments
Author:
erics, July 16th, 2019
Tungsten Clustering provides high availability, disaster recovery, and a host of other benefits for MySQL / MariaDB / Percona Server databases. In this blog post we will explore some of the shell aliases I use every day to administer various Tungsten Clusters.
Categories: Mastering Tungsten Clustering, Monitor Tags: Aliases, bash, cli, Command, Command line, HA, High Availability, monitoring, mysql, Tungsten
|
Comments Off on Slick Command-Line Tricks for a Tungsten MySQL / MariaDB Database Cluster
Author:
erics, February 3rd, 2016
There are times when the hackers slam my servers and the load gets too high. I use a very simple bash script as a cron job to monitor the load and take action when it gets too high. The script will stop httpd, sleep for a configurable period of time (currently 3 minutes), then start […]
Categories: How-To's, Technology Tags: apache, apachectl, bash, Cron, howto, httpd, Restart, tips
|
No comments
Author:
erics, December 8th, 2015
As always, YMMV…
|
#!/bin/bash # Usage: eject [fullpath to mount point] DISK="${1:-/Volumes/YourUSBFlashDriveName/}" df -h "$DISK" > /dev/null 2>&1 if [ $? -eq 0 ]; then diskutil unmountDIsk `diskutil list "$DISK" | grep ^/dev/` else echo Volume $DISK is not mounted...skipping. fi |
Categories: How-To's, Technology Tags: apple, bash, cli, Command, Command line, Disk, diskutil, Drive, eject, Flash, howto, List, Mac, macosx, mount, Terminal, tips, umount, unmount, unmountDisk, USB, volume
|
No comments
Author:
erics, September 15th, 2015
The script to check and restart apache…works on CentOS – YMMV!
|
#!/bin/bash MAXLOAD=6 check=$(uptime | awk -F'average: ' '{print $2}' | awk '{print $1}' | tr -d ',') if [[ $check > $MAXLOAD ]]; then /sbin/service httpd stop HOST=`hostname` echo $HOST | mailx -s "$HOST load alert - apache STOPPED by cron script" load.alert@your.domain sleep 300 /sbin/service httpd start echo $HOST | mailx -s "$HOST load alert - apache STARTED by cron script" load.alert@your.domain fi |
Add to cron * * * * * /root/restart_apache_if_load_hits_threshold.sh >> /var/log/restart_apache_if_load_hits_threshold.log 2>&1
Categories: How-To's, Technology Tags: apache, AWK, bash, CentOS, howto, httpd, Load, load average, Restart, Stop, tips, Uptime
|
No comments
Author:
erics, July 7th, 2015
The Readline library has a bell-style variable that controls what happens when Readline wants to ring the terminal bell. If set to ‘none’, Readline never rings the bell. If set to ‘visible’, Readline uses a visible bell if one is available. If set to ‘audible’ (the default), Readline attempts to ring the terminal’s bell. Edit […]
Categories: How-To's, Technology Tags: apple, bash, Bell, howto, inputrc, macosx, readline, Ring, Terminal Bell, tips
|
No comments
Author:
erics, February 27th, 2015
|
#!/bin/bash for line in `cat file.txt`; do echo line: $line done |
|
#!/bin/bash for file in $( ls ); do echo filename: $file done |
|
#!/bin/bash for i in `seq 1 10`; do echo $i done |
Categories: How-To's, Technology Tags: bash, howto, Loop, tips
|
No comments
Author:
erics, January 1st, 2015
awk ‘{sum+=$1}END{print sum}’ inputFile
Categories: How-To's, Technology Tags: Add, AWK, bash, Command line, howto, Math, Shell, Sum, tips
|
No comments