Tuesday, April 15, 2014

Using while to run a command number of times + UNIX

Hi Friends,

We can use while to run a command multiple times with a time difference of n seconds.

[root@abc /]# while true
> do sleep 10
> df -h
> done
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   19G   28G  41% /
tmpfs                 935M  408K  935M   1% /dev/shm
/dev/sda1             485M   38M  422M   9% /boot
/dev/mapper/VolGroup-lv_home
                       50G  5.5G   42G  12% /home
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   19G   28G  41% /
tmpfs                 935M  408K  935M   1% /dev/shm
/dev/sda1             485M   38M  422M   9% /boot
/dev/mapper/VolGroup-lv_home
                       50G  5.5G   42G  12% /home
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   19G   28G  41% /
tmpfs                 935M  408K  935M   1% /dev/shm
/dev/sda1             485M   38M  422M   9% /boot
/dev/mapper/VolGroup-lv_home
                       50G  5.5G   42G  12% /home

===========


the output of df command is coming after every ten seconds. these can be used when monitoring the size of file system while reducing it using find or rm.

Love Sharing
Amit Chopra

No comments: