Category: shell
-
Unix – Seqential Remote Calls to Several Machines
Copy Data to multiple machines for i in 187 135; do echo “–server${i}–“; scp -p -r /dev/mydata myuser@myhost${i}.net:/dev ; done Execute Scripts in multiple machines Example 1 for i in 187 135; do echo “–server${i}–“; ssh myuser@myhost${i}.net “chmod 777 /dev/mydata.sh;rm -r /dev/main;” ; done Example 2 for i in 187 135; do echo “——de${i}——–“; ssh…
-
Postgres – Executing SQL-Statement in several remote machines sequentially
echo ‘psql -a -d mydatabase -p 5432 -c “\d mytable;”‘| ssh myuser@myserverhost.net ‘sudo su – postgres -c “bash -x — ” ‘ echo ‘psql -a -d mydatabase -p 5432 -c select id from mytable where id = 393050;”‘| ssh myuser@myserverhost.net ‘sudo su – postgres -c “bash -x — ” ‘
-
Unix – Check and Monitor Open Ports and established Connections
lsof -i lsof -i | less # firefox example lsof -i | grep firefox check every second while [ “1” ] ; do clear; lsof -i; sleep 1; done; # firefox example while [ “1” ] ; do clear; lsof -i | grep firefox; sleep 1; done; netstat |grep localhost while [ “1” ] ;…
-
Unix – disk and file size monitoring with du, df and stat
du – file space usage GB sized files and directories du -xh DIRPATH |egrep “^[0-9\.]+[GT]\s” # Examples du -xh ~/ |egrep “^[0-9\.]+[GT]\s” sudo du -xh / |egrep “^[0-9\.]+[GT]\s” Size Of Directory and Disk Space du -s .archived/ du –sk # k: output in in KB # x=> expands, only on the local file system –…
-
Linux – IO Wait Monitoring – Top, IOStat and WMStat
1. Top top -c column wa => io wait 2. IOStat Installation sudo apt-get install -y sysstat iostat -k 3 IO History ls /var/log/sysstat/sa[0-9]* Select a File, e.g. sar -u -f /var/log/sysstat/sa17 3. VMStat vmstat 5 120 Help: vmstat –help Usage: vmstat [options] [delay [count]] Options: -a, –active active/inactive memory -f, –forks number of forks…
-
Unix – Executing Top once or Every X Seconds
Top Every Second -Version 1 top -c -b Top Every Second -Version 2 top -c -b -d 1 Top Every 5 Seconds top -c -b -d 5 Top Only once top -c -b -n 1 top -h procps-ng version 3.3.3 usage: top -hv | -bcHiSs -d delay -n limit -u|U user | -p pid[,pid] -w…
-
Unix – Show, Create and Delete Command Alias
Define an Alias The first example causes ls -l to be executed when the command ll is entered: alias ll ls -l Show all defined Alias alias Show Alias for specific Alias alias ls Alias File – .bash_aliases The alias file located in ~/.bash_aliases is executed on startup. Below is an example of .bash_aliases. cat…
-
Postgres – Which users are Currently Connected to the database
Postgres Database – Who is Currently Connected SELECT * FROM pg_stat_activity order by client_addr;
-
Unix – ps – finding running processes
ps -fA|grep postgres PS(1) User Commands PS(1) NAME ps – report a snapshot of the current processes. SYNOPSIS ps [options] DESCRIPTION ps displays information about a selection of the active processes. If you want a repetitive update of the selection and the displayed information, use top(1) instead. This version of ps accepts several kinds of…