Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Small script 2

Status
Not open for further replies.

xyz786

IS-IT--Management
Apr 5, 2006
45
US
I need to run four commands
1.if rootvg has more than 1gb free space create a logical volume with 1 LP (least size depending on PPs like 16, 32, 128, 256).otherwise exit (If the name of server xy1abcd01 then LV name should be in the format lvxbcd1_vcl)
2.create and mount a file system using the above LV
3.File system should have atleast 256 MB in size
4.Run a command ???? (this command runs an application)

I tried it out using
vg_size=`lsvg rootvg|grep FREE|cut -d '(' -f 2 | cut -d ' ' -f 1` then if - else condition , if it is <1024 then exit otherwise create LV.then wrote a long script which doesn't look good. Can somebody help me out to complete this script (small).

Thanks

 
here is your (small) script :)

Code:
#!/bin/sh

FREEPP=`lsvg rootvg | grep FREE | awk '{ print $7 }'| cut -d '(' -f 2`

if [ $FREEPP -lt 1024 ]
then
echo "rootvg Less than 1GB!!!"
else
echo "Creating an lv"
mklv -y $(hostname)'_vcl' rootvg 1
sleep 10
#/usr/sbin/crfs -v jfs -d$(hostname)'_vcl' -m'/myfs' -A''`locale nostr | awk -F: | '{print $1}'`'' -p'rw' -t''`locale nostr | awk -F: '{print $1}'`'' -a | frag='4096' -a nbpi='4096' -a ag='8'

/usr/sbin/crfs -v jfs -d$(hostname)'_vcl' -m'/myfs'
sleep 10
mount /dev/$(hostname)_vcl
fi

I hope that would be helpfull :)

Regards,
Khalid
 
sorry i just forgot to remove my commented out command :p

Code:
#!/bin/sh

FREEPP=`lsvg rootvg | grep FREE | awk '{ print $7 }'| cut -d '(' -f 2`

if [ $FREEPP -lt 1024 ]
then
echo "rootvg Less than 1GB!!!"
else
echo "Creating an lv"
mklv -y $(hostname)'_vcl' rootvg 1
sleep 10
/usr/sbin/crfs -v jfs -d$(hostname)'_vcl' -m'/myfs'
sleep 10
mount /dev/$(hostname)_vcl
fi

That looks better :)

Regards,
Khalid
 
Khalidaa, Thanks for the script, but the main thing i need to consider is If the name of server is xy1abcd01 then LV name should be in the format lvxbcd1_vcl [lv,first letter in the hostname, 5, 6, 7th letters and then the numeric number)] .This is just for consistensy . So I am not using the host name as it is in the LV name. Can you take a look in to this?
 
xyz786,

Hope the below modified script will help as requested above.

#!/bin/sh

FREEPP=`lsvg rootvg | grep FREE | awk '{ print $7 }'| cut -d '(' -f 2`

if [ $FREEPP -lt 1024 ]
then
echo "rootvg Less than 1GB!!!"
else
echo "Creating an lv"
lvname=lv`hostname|cut -c 1,5-7`1_vcl
mklv -y $lvname rootvg 1
sleep 10
/usr/sbin/crfs -v jfs -d /dev/$lvname -m /myfs -A yes
sleep 10
mount /myfs
fi


aixnag
IBM Certified Specialist - P-series AIX 5L Administration
IBM Certified Specialist - AIX V4 HACMP
IBM eServer Certified Specialist – p690 Technical Support
IBM Certified Solutions Expert - DB2 UDB V7.1 Database Administration for Unix, Linux, Windows and OS/2
 
Thanks aixnag. I just changed this line lvname=lv`hostname|cut -c 1,5-7`1_vcl to lvname=lv`hostname|cut -c 1,5-8`_vcl, it works fine.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top