- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script required to move files from (/oracle/SID/or...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014 05:46 AM
05-30-2014 05:46 AM
Hi every one,
I new scripting in HP unix operating system.
I require a script, which do the following given below example.
When '/oracle/<SID>/oraarch' filesystem usage is 80%. It has to move '*.dbf' files from '/oracle/<SID>/oraarch' to '/oracle/<SID>/sapdata6'.
And
if '/oracle/<SID>/sapdata6' filesystem usage is 90%. It has to move '*.dbf' files from '/oracle/<SID>/oraarch' to '/oracle/<SID>/sapdata7'
And
if '/oracle/<SID>/sapdata7' filesystem usage is 90%. It has to move '*.dbf' files from '/oracle/<SID>/oraarch' to '/oracle/<SID>/sapdata8'
And
if '/oracle/<SID>/sapdata8' filesystem usage is 90%. It has to delete '*.dbf' files from '/oracle/<SID>/sapdata6' and it has to move '*.dbf' files from '/oracle/<SID>/oraarch' to '/oracle/<SID>/sapdata6'
And
if '/oracle/<SID>/sapdata6' filesystem usage is 90%. It has to delete '*.dbf' files from '/oracle/<SID>/sapdata7' and it has to move '*.dbf' files from '/oracle/<SID>/oraarch' to '/oracle/<SID>/sapdata7'
And
if '/oracle/<SID>/sapdata7' filesystem usage is 90%. It has to delete '*.dbf' files from '/oracle/<SID>/sapdata8' and it has to move '*.dbf' files from '/oracle/<SID>/oraarch' to '/oracle/<SID>/sapdata8'.
Please help me for this script. It is very important for daily routine task.
Thanks in Advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014 01:55 PM - edited 06-02-2014 09:54 AM
05-30-2014 01:55 PM - edited 06-02-2014 09:54 AM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
You need to break your requirements into smaller tasks that can be done by separate functions or scripts.
1) You seem to need a function to return usage of a filesystem.
2) A function to move files
3) A function to delete files.
You then call the above functions passing the various sources and targets:
SID=XXX
FS=/oracle/$SID/oraarch
src=$FS
TGT=/oracle/$SID/sapdata6
usage_limit=80
usage=$(get_fs_usage $FS)
if [ $usage -ge $usage_limit ]; then
move_files $src $TGT
fi
FS=/oracle/$SID/sapdata6
TGT=/oracle/$SID/sapdata7
usage_limit=90
usage=$(get_fs_usage $SRC)
if [ $usage -ge $usage_limit ]; then
move_files $src $TGT
fi
FS=/oracle/$SID/sapdata7
TGT=/oracle/$SID/sapdata8
usage=$(get_fs_usage $SRC)
if [ $usage -ge $usage_limit ]; then
move_files $src $TGT
fi
FS=/oracle/$SID/sapdata8
TGT=/oracle/$SID/sapdata6
usage=$(get_fs_usage $SRC)
if [ $usage -ge $usage_limit ]; then
remove_files $TGT
move_files $src $TGT
fi
...
You could combine the steps that have to delete with the ones that don't by passing a parm to indicate that step. And then you can use the same function to do all 6 steps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2014 04:47 AM
06-02-2014 04:47 AM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
To get percentage value of filesystem. I written the script given below.
SID=XXX
FS=/oracle/$SID/oraarch
src=$FS
TGT=/oracle/$SID/sapdata6
usage_limit=80
usage=$(bdf | egrep "/oracle/RRP/oraarch" | awk '{print $5}')
echo "$usage"
if [ $usage -ge $usage_limit ]; then
mv $SRC $TGT
fi
After executing the script, I got the following error.
# ./scriptoraarch.sh
28%
./scriptoraarch.sh[8]: 28%: Expression is not complete; more tokens expected.
You have mail in /var/mail/root
#
I need to remove the percentage(%) symbol from the number (ex.28%). which comes output of following line usage=$(bdf | egrep "/oracle/XXX/oraarch" | awk '{print $5}').
Please help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2014 08:35 AM
06-02-2014 08:35 AM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2014 09:55 AM - edited 07-03-2014 03:27 PM
06-02-2014 09:55 AM - edited 07-03-2014 03:27 PM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
>I need to remove the percentage(%) symbol from the number
You can simply do it with awk, also no need to use the egrep hammer:
usage=$(bdf $FS | awk '{print substr($5, 1, length($5)-1}')
Note: If your filesystem string is too long to fit, bdf(1) will display on two lines.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2014 03:44 AM
07-03-2014 03:44 AM
SolutionHi
I had done my self. I done the script in another way. Script given below.
#Initiliaze Values in varaiables
SID=XXX
FS=/oracle/$SID/oraarch
src=$FS
TGT_SD6=/oracle/$SID/sapdata6
TGT_SD7=/oracle/$SID/sapdata7
TGT_SD8=/oracle/$SID/sapdata8
#Calculating the usage limit of the filesystem /oracle/$SID/oraarch by 70 percentage
ora_lt=$(bdf | egrep "/oracle/$SID/oraarch" | awk '{print $2}')
ora_lt_div=$((ora_lt/100))
ora_lt_p=$((ora_lt_div*70))
#echo "$ora_lt_p"
#Calculating the usage of the filesystem /oracle/$SID/oraarch
ora_gw=$(bdf | egrep "/oracle/$SID/oraarch" | awk '{print $3}')
#Calculating the usage limit of the filesystem /oracle/$SID/sapdata6 by 60 percentage
SD6_lt=$(bdf | egrep "/oracle/$SID/sapdata6" | awk '{print $2}')
SD6_lt_div=$((SD6_lt/100))
SD6_lt_p=$((SD6_lt_div*60))
#echo "$SD6_lt_p"
#Calculating the usage of the filesystem /oracle/$SID/sapdata6
SD6_gw=$(bdf | egrep "/oracle/$SID/sapdata6" | awk '{print $3}')
#Calculating the usage limit of the filesystem /oracle/$SID/sapdata7 by 50 percentage
SD7_lt=$(bdf | egrep "/oracle/$SID/sapdata7" | awk '{print $2}')
SD7_lt_div=$((SD7_lt/100))
SD7_lt_p=$((SD7_lt_div*50))
#echo "$SD7_lt_p"
#Calculating the usage of the filesystem /oracle/$SID/sapdata7
SD7_gw=$(bdf | egrep "/oracle/$SID/sapdata7" | awk '{print $3}')
#Calculating the usage limit of the filesystem /oracle/$SID/sapdata8 by 40 percentage
SD8_lt=$(bdf | egrep "/oracle/$SID/sapdata8" | awk '{print $2}')
SD8_lt_div=$((SD8_lt/100))
SD8_lt_p=$((SD8_lt_div*40))
#echo "$SD8_lt_p"
#Calculating the usage of the filesystem /oracle/$SID/sapdata8
SD8_gw=$(bdf | egrep "/oracle/$SID/sapdata8" | awk '{print $3}')
#Checking usage growth with usage limit and moves *.dbf files to sapdata6, sapdata7 & sapdata8 file systems
if [ $ora_gw -ge $ora_lt_p ] && [ $SD6_gw -le $SD6_lt_p ]
then
find $SRC -type f -name RRParch1*.dbf -mtime +1 -exec mv -f {} $TGT_SD6 \;
elif [ $ora_gw -ge $ora_lt_p ] && [ $SD6_gw -ge $SD6_lt_p ] && [ $SD7_gw -le $SD7_lt_p ]
then
find $TGT_SD6 -type f -name RRParch1*.dbf -exec mv -f {} $TGT_SD7 \;
find $SRC -type f -name RRParch1*.dbf -mtime +1 -exec mv -f {} $TGT_SD6 \;
elif [ $ora_gw -ge $ora_lt_p ] && [ $SD6_gw -ge $SD6_lt_p ] && [ $SD7_gw -ge $SD7_lt_p ] && [ $SD8_gw -le $SD8_lt_p ]
then
find $TGT_SD7 -type f -name RRParch1*.dbf -exec mv -f {} $TGT_SD8 \;
find $TGT_SD6 -type f -name RRParch1*.dbf -exec mv -f {} $TGT_SD7 \;
find $SRC -type f -name RRParch1*.dbf -mtime +1 -exec mv -f {} $TGT_SD6 \;
elif [ $ora_gw -ge $ora_lt_p ] && [ $SD6_gw -ge $SD6_lt_p ] && [ $SD7_gw -ge $SD7_lt_p ] && [ $SD8_gw -ge $SD8_lt_p ]
then
find $TGT_SD8 -type f -name RRParch1*.dbf -exec rm -f {} \;
find $TGT_SD7 -type f -name RRParch1*.dbf -exec mv -f {} $TGT_SD8 \;
find $TGT_SD6 -type f -name RRParch1*.dbf -exec mv -f {} $TGT_SD7 \;
find $SRC -type f -name RRParch1*.dbf -mtime +1 -exec mv -f {} $TGT_SD6 \;
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2014 05:24 AM - edited 07-03-2014 05:30 AM
07-03-2014 05:24 AM - edited 07-03-2014 05:30 AM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
bdf can be very slow on big systems, especially if there are NFS mounts.
Here is a way to write scripts to only call bdf once, only for local filesystems, and handle split lines:
export BDF=$(bdf -l | while read FS TOT USED AVAIL PERCENT MNT do if [[ $FS != "Filesystem" ]] then if [[ "$TOT" = "" ]] then read TOT USED AVAIL PERCENT MNT fi echo "$(echo $FS $TOT $USED $AVAIL $PERCENT $MNT | tr -d '%')" fi done)
Now in the rest of the script, you replace the bdf command with $(echo "$BDF") as in:
$(echo "$BDF") | grep $FS
(note: $BDF has the % character removed to make parsing the percentage value easier)
Since the bdf text is all in memory, the results are very fast and don't require any help from HP-UX.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2014 01:00 AM
07-04-2014 01:00 AM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
You can make several optimizations:
((ora_lt_div = ora_lt / 100))
And no need to compute ora_lt_div:
((ora_lt_p = ora_lt / 100 * 70))
>ora_lt=$(bdf | egrep "/oracle/$SID/oraarch" | awk '{print $2}')
There is no need to use egrep and if /oracle is a filesystem, you can simply to:
ora_lt=$(bdf "/oracle/$SID/oraarch" | awk '{print $2}')
And awk can do the percentage calc too:
ora_lt=$(bdf "/oracle/$SID/oraarch" | awk 'BEGIN {OFMT="%.0f"} {print $2 * .70 }')
And of course, there is no reason awk can't compute the limit and usage in the same line. You would need to assign to an array.
find $TGT_SD8 -type f -name RRParch1*.dbf -exec rm -f {} + # Using "+" is much faster
For numeric variables you can use C style expressions:
if (( ora_gw >= ora_lt_p && SD6_gw <= SD6_lt_p )); then
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 05:09 AM
07-16-2014 05:09 AM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
Hello,
Now in the rest of the script, you replace the bdf command with $(echo "$BDF") as in: $(echo "$BDF") | grep $FS
i get an error , when i use this it ?
do you mean?
echo "$BDF" | grep $FS
it test it with "echo "$BDF" | grep/tmp"
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2014 01:15 AM
07-17-2014 01:15 AM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
>do you mean? echo "$BDF" | grep $FS
Yes, that makes more sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2014 05:13 PM - edited 07-17-2014 05:13 PM
07-17-2014 05:13 PM - edited 07-17-2014 05:13 PM
Re: script required to move files from (/oracle/SID/oraarch) to (/oracle/SID/sapdata6)
You and Dennis are correct. Just echo the BDF variable using quotes and grep for the mountpoint:
"echo "$BDF" | grep /tmp
Bill Hassell, sysadmin