Thanks to antville.org
Tuning MySQL

Getting the shell script:
wget launchpadlibrarian.net

Running:
sh tuning-primer.sh

... Link (0 comments) ... Comment


Check for table corruption quick and fast

!/bin/sh

for dbname in mysqlshow | awk '{print $2}'
do
mysqlcheck $dbname ticket -Fq
done

call this shell script and find the errors

time sh check.sh | grep error

... Link (0 comments) ... Comment


shell script example

An example of shell script.
This will print numbers 0 to 500 in one line.

!/bin/bash

Z=0
LIMIT=500
while [ "$Z" -lt "$LIMIT" ]

do
echo -n "$Z... "
Z=$( expr $Z + 1 )
done
echo
exit 0


ping the address received from positional parameter

!/bin/bash

if [ $# -eq 0 ]
then
SITE="google.com"
else
SITE="$1"
fi

ping -c 2 $SITE > /dev/null
if [ $? != 0 ]
then
echo $(date +%F) ... Network Failure!
fi


Here is the script that will loop two thousand times and print the statement on the screen.

!/bin/sh

MAX=2000
i=1
echo " truncate table t1; "

while [ $i -le $MAX ]
do
echo " insert into t1(f1) values($i); "
i=expr $i + 1
done

... Link (0 comments) ... Comment


Match Operator in AWK

The match operator is the tilde “~” which will match an expression in a record or field. In this example awk is used to search for a field, number 7, that matches “nologin”.

awk -F: '$7 ~ /nologin/' /etc/passwd
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin

... Link (0 comments) ... Comment


Copy table

!/bin/sh

for i in find /var/lib/mysql/test/ -name "Table1.*"
do
cp $i dirname $i'/test'basename $i
done

duplicate a table Table1 by coping the files if it is a MyISAM table.

... Link (0 comments) ... Comment


Brace Expansion

Brace expansion is used to generate arbitrary strings. For e.g.
ls mysql*.0000{1..3}

will list the files like mysql.00001 mysql.00002 & mysql.00003

This can also be used for something like this...

cp mysql.log{,.bak}

cp mysql.log mysql.log.bak

cp $da.log{.bak,}

cp 2010-05-28.log.bak 2010-05-28.log

... Link (0 comments) ... Comment


User input in shell script

!/bin/sh

unset REPLY
until [[ $REPLY ]]; do read -p "Enter your name: "
done
echo "welcome $REPLY"

... Link (0 comments) ... Comment


Inernal File Separator

The safe way to change IFS in a 'while read' loop is:

while IFS=| read a b c
do
: whatever
done

... Link (0 comments) ... Comment


valid date

validdate.sh script will look like this...

!/bin/sh

userdate=$1
date -d $userdate &> /dev/null
if [ $? -ne 0 ] ; then
echo You entered an invalid date, $userdate
else
echo The date $userdate is valid
fi

sh validdate.sh 2009-33-44

You entered an invalid date, 2009-33-44

... Link (0 comments) ... Comment


better code

test -s /var/log/mailme.txt
if [[ $? -eq 0 ]] ; then
The above 2 lines can be written in one line as shown below:

if [[ -z /var/log/mailme.txt ]]; then

... Link (0 comments) ... Comment


Online for 6838 days
Last modified: 5/7/21 5:46 AM
Status
Youre not logged in ... Login
Menu
... Home
... Tags

Search
Calendar
May 2021
SunMonTueWedThuFriSat
1
2345678
9101112131415
16171819202122
23242526272829
3031
December
Recent updates
Preserve seeds 6 types of
seeds to be preserved for next season. 1) laal Mula...
by shantanuo (5/7/21 5:46 AM)
Why do I care for
Linux? I don't care that much for other software. Linux...
by shantanuo (12/17/20 9:27 AM)
important leafy vegetables 1. Amaranthus
caudatus: rajgira. 2. Amaranthus tricolor: Math.  (Chhoti Chulai- Hindi, Cheera-...
by shantanuo (4/12/20 2:01 PM)
program creek program creek
seems to be a good site for handy references of python...
by shantanuo (4/11/20 11:24 AM)
Standard out to a file
This code will change the standard out to a file...
by shantanuo (4/11/20 11:18 AM)
Create config file for AWS
command line tool While creating amazon config file in a...
by shantanuo (2/20/20 6:00 AM)
setting colors in pandas This
is how to set the colors in pandas mapper =...
by shantanuo (2/20/20 5:53 AM)
log mysql output tee output.txt
show global variables; show engine innodb status\G show full processlist;...
by shantanuo (2/19/20 10:33 AM)
access AWS API gateway using
python Amazon API gateway allows us to host serverless API's...
by shantanuo (2/16/20 9:41 AM)
Using boto In the bad
old days, the glacier class used to have different layers....
by shantanuo (2/15/20 10:28 AM)
backup mysql users  3
steps to install percona utility... yum install perl-DBI perl-Data-Dumper perl-DBD-MySQL wget...
by shantanuo (2/13/20 1:49 PM)
Steps to be used for
generating AWS API gateway a) Method Execution - Get Method...
by shantanuo (2/13/20 1:30 PM)
apply colors to pandas Here
is how to change the color of negative values to...
by shantanuo (2/12/20 8:57 AM)
Holidays in India These are
the common holidays celebrated in India (Mumbai) during 2016 -...
by shantanuo (2/11/20 1:53 PM)
change log file size in
MySQL Here are the steps to be followed while changing...
by shantanuo (2/11/20 10:38 AM)
MySQL common error messages 1146
Table does not exist 1054 column does not exist 1062...
by shantanuo (2/11/20 10:13 AM)
ipython parallel demo First start
ipython in cluster mode ipcluster start -n 4 from IPython.parallel...
by shantanuo (2/9/20 9:02 AM)
djanog settings You may see
this message if you have DEBUG = True in your...
by shantanuo (2/9/20 4:07 AM)
clear tmp folder Here is
following commands to clear unwanted stuff from the /tmp partition...
by shantanuo (2/8/20 2:41 PM)
change your server time to
IST If you need to change your server clock to...
by shantanuo (2/8/20 2:39 PM)
Transfer root emails to another
email address If you have root access to the server...
by shantanuo (2/8/20 2:32 PM)
special strings in cron Instead
of the first five fields, you can use any one...
by shantanuo (2/8/20 2:30 PM)
LibreOffice version conflict I am
not able to install latest version of Libre office. I...
by shantanuo (1/29/20 9:15 AM)
while loop This is
a sample shell script while loop while read mydb do echo...
by shantanuo (1/26/20 12:24 PM)
compare mysql schema And here
is poor man's schema compare using good old diff command......
by shantanuo (1/26/20 11:49 AM)

RSS feed

Made with Antville
Helma Object Publisher