Wednesday, February 24, 2016

To run a command repeatedly in Linux

For many cases, we need to execute the command repeatedly in the shell. We can do it by cron. But in that cat its not feasible to use cron if the interval time is less than 1 min or more. Suppose, we are inclined to get the output like the top command for a specific command. We can do that in the following ways as:
watch Command
# watch free -m [By Default 2 Sec Interval]
# watch -n 10 script.sh [For the interval of 10 Seconds]
Sleep Command:
a) inside For Loop
# for i in {1..10}; do echo -n "This is a test in loop $i "; date ; sleep
b) Inside while Loop
# while true; do echo -n "This is a test of while loop";date ; sleep 5; done

Wednesday, February 17, 2016

Creating DB Link in Oracle Database

At first we need to add the desired database connection info in tnsnames.ora file. Usually location of tnsnames.ora file in $ORACLE_HOME/network/admin.  We will add connection info as below:

 <connection_name> =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <db_host_name>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = <remote_db_service_name>)
    )
  )

Monday, February 8, 2016

SARMON: nmon for Solaris

nmon (short hand for Nigel's Monitor) is a computer performance system monitor tool for the AIX and Linux operating systems developed by IBM employee Nigel Griffiths.
SARMON is for Solaris machine with the functionality of nmon.
The installation is very ease
1. Get the .zip file form Sarmon Download Link
2. Save on /var/tmp
3. Unzip the .zip
# unzip sarmon_v1.01.bin_sparc.zip
4. Make backup of original files
# cp /usr/bin/sar /usr/bin/sar.orig
# cp /usr/bin/timex /usr/bin/timex.orig
# cp /usr/lib/sa/sadc /usr/lib/sa/sadc.orig
5. Move the sarmon to /usr/local
# mv /var/tmp/sarmon_v1.01.bin_sparc /usr/local/sarmon
6. Copy files
# cp /usr/local/sarmon/sar /usr/bin/sar
# cp /usr/local/sarmon/timex /usr/bin/timex
# cp /usr/local/sarmon/sadc /usr/lib/sa/sadc
7. Edit the crontab and put the entry for collect
0 0 * * * /usr/local/sarmon/sa1 300 288 &
This start collect every day at 00:00
The files generated are in /var/adm/sa/ (day-by-day)