Sponsored Content
Full Discussion: Troubleshooting Script
Top Forums Shell Programming and Scripting Troubleshooting Script Post 65375 by muthukumar on Friday 4th of March 2005 11:38:05 PM
Old 03-05-2005
I tried to edit the script (without testing) as,
Code:
#!/bin/ksh

# Variables
email_addresses="tina.naugler@cgi.com m.harley@cgi.com pamela.green@cgi.com"
set -A instance "ont0" "qbc1" "jdbc0" "admin1"
set -A fName "nohup.out" "PHLog.txt" "PSQTlog.txt" "response-Log.txt" "access.log" "wl-domain.log" "weblogic.log" "ServiceAddressQueryResponse.Log.txt"

# these variables will contain the system date to append to the file name
# the DATEday variable can be altered for mid-month backups (but it MUST be reset to the 7th 
after backup completed)
DATEday=7
DATEmonth=$(( \( "`date +%m`" + 12 - 1 \) % 12 ))
DATEyear="`date +%y`"

# filler variables
zero="0"
star="*"
underscore="_"

# if the current month is January, then the backup will be for December of the previous year
function setYear {
  if [ ${DATEmonth} -eq 1 ]
  then
    let DATEyear=DATEyear-1
  fi
}

# send the temp file in the body of an email to the email addresses specified above
function sendEmails {
  
  index=0
  while [[ $index -lt ${#email_addresses[*]} ]]
  do
  
    let email_address=${email_addresses[$index]}
    /bin/mail -s "${DATEday}-${DATEmonth}-${DATEyear} Log File Backup" $email_address < /tmp/ebccsbkup.tmp
    let index=index+1
    
  done
}
# backup files and compress them, then move them to the backup directory for the instance
# the results of the executed commands is written to a temp file
function backupFiles {
	
  let y=0;
  while [[ $y -lt ${#fName[*] ]] 
  do
    if [ ${fName[y]} = "access.log" ] || [ ${fName[y]} = "weblogic.log" ]; then
      if [ -f "access.log" ] || [ -f "weblogic.log" ]; then
        tar cvf bk${fName[y]}.${DATEyear}${DATEmonth}.tar ${fName[y]}.${zero}${star} >> /tmp/ebccsbkup.tmp
        mv bk${fName[y]}.${DATEyear}$DATEmonth.tar $fName[y].${DATEyear}${DATEmonth}${underscore}${DATEday}.tar >> /tmp/ebccsbkup.tmp
        gzip ${fName[y]}.${DATEyear}${DATEmonth}${underscore}${DATEday}.tar >> /tmp/ebccsbkup.tmp
      else
        echo "${fName[y]} does not exist in ${instance[x]}" >> /tmp/ebccsbkup.tmp
      fi
    elif [${fName[y]} = "wl-domain.log"]; then
      if [ -f "wl-domain.log" ]; then
        tar cvf ${fName[y]}.${DATEyear}${DATEmonth}${underscore}${DATEday}.tar ${fName[y]} >> /tmp/ebccsbkup.tmp
        gzip ${fName[y]}.${DATEyear}${DATEmonth}${underscore}${DATEday}.tar >> /tmp/ebccsbkup.tmp
      else
        echo "${fName[y]} does not exist in ${instance[x]}" >> /tmp/ebccsbkup.tmp
      fi
    else
      if [ -f $fName[y]} ]; then
        tar cvf bk${fName[y]}.${DATEyear}$DATEmonth.tar ${fName[y]}.${DATEyear}$DATEmonth${star} >> /tmp/ebccsbkup.tmp
        mv bk${fName[y]}.${DATEyear}$DATEmonth.tar ${fName[y]}.${DATEyear}${DATEmonth}${underscore}${DATEday}.tar >> /tmp/ebccsbkup.tmp
        gzip ${fName[y]}.${DATEyear}${DATEmonth}${underscore}${DATEday}.tar >> /tmp/ebccsbkup.tmp
      else
        echo "${fName[y]} does not exist in ${instance[x]}" >> /tmp/ebccsbkup.tmp
      fi
    fi
    echo "\n" >> /tmp/ebccsbkup.tmp
    let y=y+1
    
  done

  mv *.tar.gz /u01/${instance[x]}/ >> /tmp/ebccsbkup.tmp
}

# loop through the instances and call function backupFiles
function setInstance {
  echo "eBCCS Monthly Log Backup ${DATEday}-${DATEmonth}-${DATEyear}" > /tmp/ebccsbkup.temp
  let x=0
  while [[ $x -lt ${#instance[*]} ]]
  do
    echo "${instance[x]} testing..."
    echo "\n" >> /tmp/ebccsbkup.tmp
    echo "${instance[x]} Log Files" >> /tmp/ebccsbkup.tmp
    cd /opt/bea/${instance[x]}/wls6.1/config/bles/logs
    backupFiles
    let x=x+1
  done
  
  sendEmails
}

setYear
setInstance

exit 0
# END ###

try this. let us know if u have problem.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

tftp troubleshooting

Hi I am trying to do a network install of Solaris 10 08_07 onto a Sunfire T2000. I have configured all my network-boot-arguments on the client server (named sundb1). I have installed my image of Solaris on my install server (sun1). But when I try to install using # boot net -s I get the... (0 Replies)
Discussion started by: Bobby76
0 Replies

2. Shell Programming and Scripting

calling a function in Shell script troubleshooting

Some Code After Some code part is executed the control doesnt go to rvin_doxx_scrt.. and the script exits rvin_doxx_scrt() { Some Code } if (som code) ... (4 Replies)
Discussion started by: ultimatix
4 Replies

3. Solaris

help troubleshooting

Hi. I have a Solaris 10 server that's taking about 20secs to respond to telnet or ftp commands. Has anyone ever seen something like that? Can you tell me where to start troubleshooting please? I logged in and did a prtstat, but nothing is jumping out as an issue. (8 Replies)
Discussion started by: bbbngowc
8 Replies

4. AIX

AIX troubleshooting

Hi guys, Is there a command in AIX similar to ps, but shows memory usage by application? I'm trying to track down a rogue application that's using up all 32GB of the available systems memory and causing the the system to page to disk. (4 Replies)
Discussion started by: bbbngowc
4 Replies

5. Ubuntu

Help with troubleshooting crontab

Hello all, When I configured cron jobs that execute bash scripts a while back on my box they worked and the other day I tried to enable cron jobs that execute a bash script to run with no success. cron text file: test.sh file The script has execution rights (e.g. if I use bash... (2 Replies)
Discussion started by: LAVco
2 Replies

6. AIX

How to Troubleshooting IO in AIX 6.xx

I am running Oracle databases and recently have been facing slow IO response. I know in 11g one can run calibrate_IO from within DB and it would have given me some data for IO, but DB is 10g. Is there any tool available which can give me max MBPS, max IO requests per second system can handle and... (1 Reply)
Discussion started by: clifford
1 Replies

7. AIX

iSCSI troubleshooting

I have an Equallogic SAN that I connect to from AIX (as well as Windows) I had configured the connection and created the volumes and filesystems and all was working great. Then one day, no communication between the SAN and the AIX (I can ping though) Anything I do on the AIX box at this time... (2 Replies)
Discussion started by: oldmanjoe
2 Replies

8. IP Networking

TCP/IP troubleshooting

Hello all, Can somebody please tell what is the best book out there that can help me learn TCP troubleshooting and understaning the TCP options like window scaling, large receive offload? I would like to understand how all the TCP tuning parameters function. Is there a book out there that can... (4 Replies)
Discussion started by: Pouchie1
4 Replies

9. Shell Programming and Scripting

Troubleshooting whiptail

Here is a code snippet using whiptail , it fails to complete giving me long list of options available for whiptail . That is great, but how do I determine which of the current opinions is wrong? I did tried inserting comment (#) into options and it just did not work. Deleting the option... (9 Replies)
Discussion started by: annacreek
9 Replies

10. Linux

Troubleshooting init.d script

This is what I did: 1. I wrote a simple init.d script (myscript.sh) 2. I placed it under /etc/init.d (where many other default scripts already are) 3. Set the perms to 755 4. Run: update-rc.d myscript.sh defaults I can run it perfectly by doing: /etc/init.d/myscript.sh start... (2 Replies)
Discussion started by: rlopes
2 Replies
DH_MOVEFILES(1) 						     Debhelper							   DH_MOVEFILES(1)

NAME
dh_movefiles - move files out of debian/tmp into subpackages SYNOPSIS
dh_movefiles [debhelperoptions] [--sourcedir=dir] [-Xitem] file...] DESCRIPTION
dh_movefiles is a debhelper program that is responsible for moving files out of debian/tmp or some other directory and into other package build directories. This may be useful if your package has a Makefile that installs everything into debian/tmp, and you need to break that up into subpackages. Note: dh_install is a much better program, and you are recommended to use it instead of dh_movefiles. FILES
debian/package.files Lists the files to be moved into a package, separated by whitespace. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory will be moved. OPTIONS
--sourcedir=dir Instead of moving files out of debian/tmp (the default), this option makes it move files out of some other directory. Since the entire contents of the sourcedir is moved, specifying something like --sourcedir=/ is very unsafe, so to prevent mistakes, the sourcedir must be a relative filename; it cannot begin with a `/'. -Xitem, --exclude=item Exclude files that contain item anywhere in their filename from being installed. file ... Lists files to move. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory will be moved. It is an error to list files here unless you use -p, -i, or -a to tell dh_movefiles which subpackage to put them in. NOTES
Note that files are always moved out of debian/tmp by default (even if you have instructed debhelper to use a compatibility level higher than one, which does not otherwise use debian/tmp for anything at all). The idea behind this is that the package that is being built can be told to install into debian/tmp, and then files can be moved by dh_movefiles from that directory. Any files or directories that remain are ignored, and get deleted by dh_clean later. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 8.9.0ubuntu2.1 2012-06-12 DH_MOVEFILES(1)
All times are GMT -4. The time now is 12:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy