Posts

MySQL export ( mysqldump ) -> ssh -> import ( mysql )

#mysqldump -uLocalUser -pLocalPassword database_name | ssh sshuser@sshhost "mysql -D remote_database_name -uRemoteUser -pRemotePassword" ( you will be asked to enter your ssh password )

Check Apache server Uptime or Mysql server uptime

MySQL -> # ps -eo "%U %c %t"| grep mysqld | grep -v grep|grep root Apache2 -> # ps -eo "%U %c %t"| grep apache2 | grep -v grep|grep root

Linux : Bash : CPU load in %

:;sleep=1;CPU=(`cat /proc/stat | head -n 1`);PREV_TOTAL=0;for VALUE in "${CPU[@]}"; do let "PREV_TOTAL=$PREV_TOTAL+$VALUE";done;PREV_IDLE=${CPU[4]};sleep $sleep; CPU=(`cat /proc/stat | head -n 1`);unset CPU[0];IDLE=${CPU[4]};TOTAL=0; for VALUE in "${CPU[@]}"; do let "TOTAL=$TOTAL+$VALUE"; done;echo $(echo "scale=2; ((($sleep*1000)*(($TOTAL-$PREV_TOTAL)-($IDLE-$PREV_IDLE))/($TOTAL-$PREV_TOTAL))/10)" | bc -l );

(MySQL) select the longest reccord in a table column

SELECT field_name FROM some_table WHERE length(field_name) = ( select max(length(field_name)) FROM some_table )

LINUX : BASH : Get multicore cpu average load in percents (%) for last minute

i=`cat /proc/cpuinfo | grep 'model name' | wc -l` ; j=`uptime | awk '{print $10 }' | tr ',' '\b'` ; Number=`echo - | awk -v K=$i -v K2=$j '{ print K*K2}'` ; echo "CPU :$Number % $i $j";

Me :)

Image

Find duplicate files on linux server

find -not -empty -type f -printf “%s\n” | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate OR  fdupes -r ./folder > duplicates_list.txt