Posts

Showing posts from March, 2017

Procedure to Reduce the Logical Volume

Scenario :   Suppose we want to reduce  /home  by 2GB which is LVM and formated as  ext4. [root@cloud ~]# df -h /home/ Filesystem            Size  Used Avail Use% Mounted on /dev/mapper/vg_cloud-LogVol00 12G  9.2G  1.9G  84% /home Step:1 Umount the filesystem [root@cloud ~]# umount /home/ Step:2 check the filesystem for Errors using e2fsck command. [ root@cloud ~]# e2fsck -f /dev/mapper/vg_cloud-LogVol00 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/mapper/vg_cloud-LogVol00: 12/770640 files (0.0% non-contiguous), 2446686/3084288 blocks Note:  In the above command  e2fsck  , we use the option  ‘-f’  to forcefully check the filesystem , even if the filesystem is clean. Step:3 Shrink the size of /home to desire size. As shown in the above scenario , size of /home is 12 GB , so by reducing

Comparing temporary and Persistant routes in Linux

Hi This script will help us to compare the routes which is persistent and which is not. ################################################################################# #!/bin/bash  ifconfig | grep addr | awk '{print $1}' > /tmp/interfaces && sed -i.bak_$time "s/inet6*//g" /tmp/interfaces  for i in $(cat /tmp/interfaces);  do  echo "******* Verifying routes on $i interface ********"  cp /etc/sysconfig/network-scripts/route-$i /tmp/route-$i  route -n | grep -i $i | grep -i ug  |awk '{print $1}' > /tmp/currentroutes  echo "***** Comparing Current and Persistant Routes on $i *****" for j in $(cat /tmp/currentroutes);          do          cat /tmp/route-$i | grep $j     if [ $? == 0 ]     then echo "***** route $j is persistent on $(hostname) *****"     else echo "#### route $j is not persistent on $(hostname) on $i ####"     fi     done  done #####################################

Crontab entries

Linux Crontab Format MIN HOUR DOM MON DOW CMD Table: Crontab Fields and Allowed Ranges (Linux Crontab Syntax) Field Description Allowed Value MIN Minute field 0 to 59 HOUR Hour field 0 to 23 DOM Day of Month 1-31 MON Month field 1-12 DOW Day Of Week 0-6 CMD Command Any command to be executed. 1. Scheduling a Job For a Specific Time The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on  10th June 08:30 AM . Please note that the time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20. 30 08 10 06 * /home/ramesh/full-backup 30  – 30th Minute 08  – 08 AM 10  – 10th Day 06  – 6th Month (June) *  – Every day of the week 2. Schedule a Job For More Than One Instance (e.g. Twice a Day) The following script take a incremental backup twice a day every day. This example executes the specified incremental backup shell script (incremental-backup) at 11:00 and 16:00 on