Showing posts with label ShellScript. Show all posts
Showing posts with label ShellScript. Show all posts

Tuesday, June 23, 2015

ShellScript - Kill process in mysql automatically


■ This is a shell script to kill process lacked.
#!/bin/bash

array_name=(`/usr/local/mysql/bin/mysql -N -e "SHOW FULL PROCESSLIST" -u root -p databasesName | grep userId | gawk -F"\t" '{print $1}' | tr '\n' ' '`);

for (( i = 0 ; i < ${#array_name[@]} ; i++ )) ; do
    echo "`/usr/local/mysql/bin/mysql -N -e "kill ${array_name[$i]}" -u root -p databasesName`";
    #echo "value[$i] = ${array_name[$i]}"
done

■ This is just memo - command
mysql>SHOW ENGINE INNODB STATUS;

Wednesday, March 18, 2015

The solutions for communicating on SSH Commend

@ If you faced the following error, the solution would help you

@ Error 1
>Pseudo-terminal will not be allocated because stdin is not a terminal.
@ the solution 1
@ [-oStrictHostKeyChecking=no] Option make a fingerprint to write in a known_hosts
@ (maybe -T -oStrictHostKeyChecking=no)
$ ssh -oStrictHostKeyChecking=no user@somehost sudo /home/tomcat/sh/sample.sh

@ Error 2
>sudo: sorry, you must have a tty to run sudo
@ the solution 1
ssh -t -oStrictHostKeyChecking=no user@somehost sudo /home/tomcat/sh/sample.sh
or
@ Comment the requiretty in /etc/sudoers like the following
#Defaults requiretty 

@ Extra explanation.
@ -T Disable pseudo-tty allocation.
@ -t Force pseudo-tty allocation.

http://aero.sarang.net/blog/2009/01/ssh-1.html

Tuesday, February 4, 2014

Shell - Calculate the sum on Shell.

@ $9 is a place where there is numbers in T.S.V.
$ cat ./logName.log | grep needWord | gawk -F'\t' '{print $9}' > sum.txt

@ Sum the values from the file.
$ awk '{s+=$1} END {print s}' ./sum.txt

Thursday, November 28, 2013

Gradle - Release Script on Jenkins

You just put the following this to the Execute shell of the Post Steps on Jenkins.

Also, you need to configure the following option on Jenkins.
Build > invoke Gradle script > Invoke Gradle Gradle Version >> Default
Build > invoke Gradle script > Tasks >> zip

Monday, May 27, 2013

Shell - init-functions

@If you want to install this /lib/lsb/init-functions on the linux?
@Just install below this.
$ yum install redhat-lsb

@=======================================
#!/bin/sh

# LSB initscript functions, as defined in the LSB Spec 1.1.0
#
# Lawrence Lim <llim@redhat.com> - Tue, 26 June 2007
# Updated to the latest LSB 3.1 spec
# http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic_lines.txt

start_daemon () {
        /etc/redhat-lsb/lsb_start_daemon "$@"
}

killproc () {
        /etc/redhat-lsb/lsb_killproc "$@"
}

pidofproc () {
        /etc/redhat-lsb/lsb_pidofproc "$@"
}

log_success_msg () {
        /etc/redhat-lsb/lsb_log_message success "$@"
}

log_failure_msg () {
        /etc/redhat-lsb/lsb_log_message failure "$@"
}

log_warning_msg () {
        /etc/redhat-lsb/lsb_log_message warning "$@"
}

Friday, May 24, 2013

Shell - init.d Script

Let's edit later.

http://werxltd.com/wp/2012/01/05/simple-init-d-script-template/