Shell script to generate Statspack every 30 min

Hi ,
I am into the situation where I need to generate the statspack every 30 min. I want to automate this this task by writing the shell script, unfortunately i am poor in shell script
do anybody have script which can implemment this functionality , I am facing problem that when spreport is called then how it will automatically pick up if start snap ID and end snap ID which should for 30 min duration.
Any quick help shell be highly appreciated. Thanks in advance.
Regards
Amit

user12098953 wrote:
Hi ,
I am into the situation where I need to generate the statspack every 30 min. I want to automate this this task by writing the shell script, unfortunately i am poor in shell script
do anybody have script which can implemment this functionality , I am facing problem that when spreport is called then how it will automatically pick up if start snap ID and end snap ID which should for 30 min duration.
Any quick help shell be highly appreciated. Thanks in advance.
Regards
Amitdo you realize that "shell script" is Operating System (OS) dependent?
Since you decided not to share your OS name & version, no answer is possible now.

Similar Messages

  • Shell script to generate redologs

    i am working on RMAN in test environment.
    beacuse there in no redo generation or very minor redo generation. i want to write a shell script that runs through cron jobs after a specific period of time and generate redo logs . This i want to do for checking RMAN mechanism of backing up archivelogs and also deletion confirmation of archivelogs through rman;
    i write a script but it is not generating redo logs
    #!/bin/sh
    export ORACLE_HOME=/opt/dev/oracle/db/tech_st/11.1.0
    cd $ORACLE_HOME
    . ./TEST_testing.env
    sqlplus / as sysdba
    sql 'alter system switch logfile';
    exit
    when i run this script only sqlplus is connected but alter system switch logfile not executed.
    please guide me. can i execute sql commands via such script or not. Moreover have a look on script as well.
    Edited by: user13376823 on Feb 16, 2011 5:06 PM

    user13376823 wrote:
    i am working on RMAN in test environment.
    beacuse there in no redo generation or very minor redo generation. i want to write a shell script that runs through cron jobs after a specific period of time and generate redo logs . This i want to do for checking RMAN mechanism of backing up archivelogs and also deletion confirmation of archivelogs through rman;
    i write a script but it is not generating redo logs
    #!/bin/sh
    export ORACLE_HOME=/opt/dev/oracle/db/tech_st/11.1.0
    cd $ORACLE_HOME
    . ./TEST_testing.env
    sqlplus / as sysdba
    sql 'alter system switch logfile';
    exit
    when i run this script only sqlplus is connected but alter system switch logfile not executed.
    That's because sqlplus never sees the statement ... think about how your shell script is proccessed. Walk through it line at a time.
    >
    please guide me. can i execute sql commands via such script or not.Yes you can, but you have to do it properly
    Moreover have a look on script as well.
    I've copied your script below and added line-by-line comments to help you see it the way the shell sees it, Each line of your code is followed by my explanation of how the shell sees that line and what it does with it.
    Edited by: user13376823 on Feb 16, 2011 5:06 PM
    #!/bin/shProcess this script using /bin/sh as the shell processor
    export ORACLE_HOME=/opt/dev/oracle/db/tech_st/11.1.0set the environment variable ORACLE_HOME to the value '/opt/dev/oracle/db/tech_st/11.1.0' and make it available to any child processes
    cd $ORACLE_HOMEchange the current directory to the directory indicated by the value of the environment variable ORACLE_HOME
    . ./TEST_testing.envexecute the file TEST_testing.env, located in the current directory. execute it in the current context
    >
    sqlplus / as sysdbaexecute sqlplus, passing it the command line parameters "/", "as", and "sysdba". It's up to sqlplus to decide what to do with that.
    >
    ----??? sqlplus is waiting for some input
    ----??? still waiting .....
    Ok, maybe you gave up and gave sqlplus an exit command, so the shell can now continue with the next line
    sql 'alter system switch logfile';shell will try to locate an executable file call "sql" and pass it the command line parm "alter system switch log file". Do you have an executable called "sql" to process that command line parm? You probably saw something like:
    ./doit.sh: line 5: sql: command not found
    >
    /and again, the shell really doesn't know what to do with this.
    >
    exitFinally the shell sees a command (exit) it recognizes.
    I did all the above to help you see why it wasn't working. The solution is to use input redirection to feed your sql commands to sqlplus.
    #!/bin/sh
    export ORACLE_HOME=/opt/dev/oracle/db/tech_st/11.1.0
    cd $ORACLE_HOME
    . ./TEST_testing.env
    sqlplus / as sysdba <<EOF
    alter system switch logfile;
    exit
    EOF
    exit >

  • Executing a shell script from a Trigger

    All,
    I have to write a script to do the following requirement.
    There is a file called BUSINESS_DATE.TXT.
    This file get updated once the oracle partition created. In Oracle, Partition will be created every day. There is a seperate script scheduled to take care ORACLE partition creation.
    The above file will have only one row. i.e
    03092012
    If Oracle partition creation job failed, the above file won't be updated.
    My requirement is,
    I have to check whether the BUSINESS_DATE file is updated today or not. If yes, I will have to move the files from common area to input file directory to process those files.
    All file name will amend with current date.
    i.e
    LIDDIFD03092012.TXT
    The key part is to check the BUSINESS_DATE.TXT file is updated properly or not.
    We don't know what time the file will get updated. So we are planning to schedule the new script to run for every 15 mins to check whether the file is updated or not
    But...I just thougt instead of writing a shell script to do the above one, Why shouldn't I capture the date in a table (New table needs to be created) and use ORACLE TRIGGER to run the shell script to move the files from common area to input file directory to process those files?
    My Proposal in ORACLE :
    Create table business_date
    rep_date varchar(15),
    curr_timestamp timestamp
    Once the oracle partition created , one row will be inserted into the above table. This adjustment needs to be implemented partition script.
    Once this table get record, TRIGGER should call SHELL SCRIPT to move the files from common area to input area.
    If I implement ORACLE TRIGGER, The script which will check whether the file got updated or not for 15 mins is not required. Right? Inputs from experts are welcome!

    >
    But...I just thougt instead of writing a shell script to do the above one, Why shouldn't I capture the date in a table (New table needs to be created) and use ORACLE TRIGGER to run the shell script to move the files from common area to input file directory to process those files?
    >
    Triggers should not be used to do transactional work. There is no COMMIT in a trigger. What happens if the trigger runs the shell script and then a ROLLBACK occurs? You will have run the shell script when it shouldn't run.
    Create a stored procedure to run the shell script. Call the stored procedure when the partition is created.
    If you were using 11g and interval paritioning you wouldn't need to create the partitions manually. Oracle could create the partitions automatically.

  • How to send an mail to my email by using shell scripting

    Hi,
    I have shell script which generates some text file with text information. Now i want to send over the information available in the text file to my mail id.
    Can anyone give me over the syntax or the script.?
    Thanks a lot
    With Regards
    Vedavathi E

    same typo
    should read
    mailx -s 'subject for mail message ' your_email_address < text_file_to_be_sent
    Guido

  • RMAN backup shell script

    Hi,
    I am trying to setup incremental backup shell script to run anutomatic every night. I am getting below errors when I run script. What am I missing here?
    oradev]/home/oradev ./RMAN_DEV_incr1.sh
    RMAN> exit
    ./RMAN_DEV_incr1.sh[13]: CONFIGURE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[14]: CONFIGURE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[15]: CONFIGURE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[16]: run: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[17]: ALLOCATE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[18]: CROSSCHECK: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[19]: BACKUP: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[20]: sql: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[21]: BACKUP: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[22]: BACKUP: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[23]: CROSSCHECK: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[24]: DELETE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[25]: DELETE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[26]: RELEASE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh: line 26: syntax error at line 27: `}' unexpected
    ==============
    Here is copy of my shell script:
    #!/bin/ksh
    # Declare your ORACLE environment variables
    export ORACLE_SID=DEV
    export ORACLE_BASE=/d01/oracle/DEV
    export ORACLE_HOME=/d01/oracle/DEV/db/tech_st/11.1.0
    export PATH=$PATH:${ORACLE_HOME}/bin
    # Start the rman commands
    rman target / msglog=/d01/RMAN/logs/rman_INCR_1_${ORACLE_SID}_${DATE}.log
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/d01/RMAN/autobackup_control_file%F';
    CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
    run {
    ALLOCATE CHANNEL RMAN_BACK_CH01 TYPE DISK;
    CROSSCHECK BACKUP;
    BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 1 DATABASE FORMAT '/d01/RMAN/databasefiles_%d_%u_%s_%T';
    sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
    BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL FORMAT '/d01/RMAN/archivelogs_%d_%u_%s_%T' DELETE INPUT;
    BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE FORMAT '/d01/RMAN/controlfile_%d_%u_%s_%T';
    CROSSCHECK BACKUP;
    DELETE NOPROMPT OBSOLETE;
    DELETE NOPROMPT EXPIRED BACKUP;
    RELEASE CHANNEL RMAN_BACK_CH01;
    EXIT;
    EOF
    #

    Hi,
    You missed to redirect the rman command
    rman target / msglog=/d01/RMAN/logs/rman_INCR_1_${ORACLE_SID}_${DATE}.log <<eof
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/d01/RMAN/autobackup_control_file%F';
    CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
    run {
    ALLOCATE CHANNEL RMAN_BACK_CH01 TYPE DISK;
    CROSSCHECK BACKUP;
    BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 1 DATABASE FORMAT '/d01/RMAN/databasefiles_%d_%u_%s_%T';
    sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
    BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL FORMAT '/d01/RMAN/archivelogs_%d_%u_%s_%T' DELETE INPUT;
    BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE FORMAT '/d01/RMAN/controlfile_%d_%u_%s_%T';
    CROSSCHECK BACKUP;
    DELETE NOPROMPT OBSOLETE;
    DELETE NOPROMPT EXPIRED BACKUP;
    RELEASE CHANNEL RMAN_BACK_CH01;
    EXIT;
    EOF
    #

  • Pass in date from shell script to java program

    Hi,
    I need to pass in some parameter to my java program.
    eg 'java SomeProgram yyyy mm dd hh mm ss'
    How do i use the shell script to generate the valeus for the year, mth day etc?
    The program is running once everyday.
    I tried $argu0 = `date+%y`
    java SomeProgram $argu0
    but not working... thanks for your help!

    Then, why would you want to use 'date' to provide
    'now' to a Java program when you could just use new
    java.util.Date() which probably makes the same call
    as the Unix 'date' command?That works until you need to use a date other than 'now.'
        public static final String ISO_DATE = "yyyy-MM-dd HH:mm:ss";
        public static void main(String[] args) {
            SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat
                    .getDateTimeInstance();
            sdf.applyPattern(ISO_DATE);
            try {
                Date d = sdf.parse(args[0]);
                // rest of code here
            } catch (ParseException e) {
                // handle exception
        }Users will have to enclose there input with quotes otherwise the JVM will consider their input as two parameters, or you can change the pattern to include a character between dd and HH.

  • I need a shell script to move latest archivelogs from one server to another server..

    Hi,
         I need a shell script to move latest archivelogs from one server to another server..
    Thanks&Regards,
    Vel

    ea816fb9-f9ea-45ac-906f-36a8315970d0 wrote:
    Thanks it's really helpfull..
    Now i have pasted a shell script which generates archivelog and shows latest archivelog time..
    just check let me know the answer, that how i need to execute it..
    # Force a logswitch to get the last archivelog to the standby host
    ORACLE_SID=ORCL
    ORAENV_ASK=NO
    . oraenv >/dev/null 2>&1
    SwitchLogfile()
      # Do logswitch 
      RESULT=`echo "Alter system switch logfile;" | sqlplus -S / as sysdba | grep 'System altered'`
      if [ "$RESULT" = "System altered." ]
      then
      export RETURN=1
      else
      export RETURN=0
      fi
      # Do we need to do something with this return value?
      export RETURN
    GetArchiveTime()
      CURYEAR=`date +%Y`
      echo "set heading off;" > temp.sql
      echo "set termout off;" >> temp.sql
      echo "select to_char(first_time,'YYYY-MM-DD HH24:MI:SS') from v\$archived_log where sequence#=(select sequence# - 1 from v\$log where status='CURRENT');" >> temp.sql
      sqlplus -S / as sysdba <
    spool tempres.txt
    @temp.sql
    quit
    EOF
    cat tempres.txt | grep ${CURYEAR} | grep -v grep | awk '{print $1" "$2}'
    #rm -f temp.sql  tempres.sql
    SwitchLogfile
    GetArchiveTime
    You seem to have ignored Dude's VERY good advice and continue to press down this ill-advised path.  If you continue this approach, you WILL have problems at the very time you do not need any additional problems.  Trying to recover your production database at 2:00 in the morning is not the time to be getting errors from rman because it can't find what it needs - because you decided to move them around yourself.
    Please reconsider.

  • Oracle 10g and Korn Shell Scripting

    I have a table,SALES_STAGING, with 3 main columns.
    Sales_Date, Sales_type,Sales_Code.
    A sale is added to the table then waits until approved to be processed. The Sales_Code is 1(waiting approval). Then manually changed to 2 every 30 minutes by sales staff except on weekends. By Monday,a large queue develops. This must be changed because the queue is slowing the system. Can someone help create a Unix Korn shell script to
    1) Run every 30 minutes via Crontab
    2)login to the Oracle DB.
    3)Count the number of records to be processed, if any.
    4)Update another 'log' table with the time it ran and the records to be processed
    5)if there are less than 20 add another 50 to be processed by changing the Sales_Code from 1 to 2.
    This would really help out tremendously! Thank you.

    Wait... Isn't this forum designed for the sharing of information? The experts here shouldn't be concerned whether the request is from a Student, Oracle newbie or Developer and should focus on the request. If you are capable of assisting then I am hoping you will out of the core respect for professionalism and the motivation to provide something of value to others. If not, don't waste my time or any one else by responding with preconceived judgments and insulting remarks as these will be reported.
    Sales transactions can peak at 20,000 per hour with an average of several million thru the week. Those sales by VIP customers are immediately identified and have a priority for approvals because their balances can easily exceed $1,000,000.00. There is a pre-approval process to be introduced but until programs can be modified/tested and deployed we need a quick fix. The programming system isn't slow, it's the limited human resources approving VIP customers. My request was to keep it simple and expand on it myself to include the entire scope of our project. dbms_scheduler, although a good idea will require DBA assistance and there is no resource available. I need a simple working model to give me some direction/ideas...

  • Shell Script - Sleep

    Hello All,
    We are printing pdf file outputs from shell script. Here we faced a problem that the shell script tried to access the output file(pdf file) while the concurrent program is running. For that we added the concurrent program names into shell script programs incompatibility list. This is working fine.
    But there are more than 20 reports using the same shell script. If all the programs are running shell script waits until all the 20 programs completed.
    I am thinking of another solution that, I have to issue a sleep command in shell script until the program completes, or until the output file is generated and the shell script can generate post script file from the output file.
    I dont know what kind of lock the concurrent program is using, because shell script says no such file or directory while generating post script file.
    Kindly help.

    You would probably find more concurrent manager experts in the Apps forums. You could try using the output of ps -ef to see if the program your script should wait for is still running. Or you can use the lsof command to see if the file you are supposed to process is still open in another process. For example, lsof -f -- /output/my.pdf shows all processes that have the file /output/my.pdf open.
    Edited by: herb on Jan 11, 2010 11:47 PM

  • Statspack report generation shell script?

    Does anyone have a shell script (unix/solaris) which does the following:
    Gets the snap_ids from the 09:00 and 17:00 statspack snapshots (from today or yesterday), and runs spreport.sql, using these snapshot ids as begin_snap and end_snap.
    I do not want to purge any snapshots from the database. I simply want to generate a daily "9 to 5" statspack report every day.
    TIA,
    Dave

    Hi,
    You can do the following way:
    1. Write script to get the begin snap_id as:
    $cat > begin_snap.sql
    set head off
    set echo off
    set verify off
    set termout off
    spool begin_snap_id.log
    SELECT snap_id
    FROM stats$snapshot
    WHERE TRUNC(snap_time) = TRUNC(SYSDATE-1)
    AND TO_NUMBER(TO_CHAR(snap_time,'HH24')) =9;
    spool off
    2. write a script to get end snap id as same as above substituting 9 with 17 with script name as end_snap.sql and spool file name as end_snap_id.log.
    3. write a script to pass arguments for spreport.sql as:
    cat > statspack_report
    #!/bin/ksh
    ORACLE_HOME=/home/oratest
    TODAY=`date '+%Y%m%d' `
    REPORT=report_${TODAY}.txt
    sqlplus -s perfstat/perfstat@database_name @$ORACLE_HOME/begin_snap.sql <<EOF
    EOF
    BEGIN_ID=`cat /home/oratest/begin_snap_id.log | sed '/^$/d' `
    sqlplus -s perfstat/perfstat@database_name @$ORACLE_HOME/end_snap.sql <<EOF
    EOF
    END_ID=`cat /home/oratest/end_snap_id.log | sed '/^$/d' `
    sqlplus -s perfstat/perfstat@database_name @$ORACLE_HOME/rdbms/admin/spreport.sql <<EOF
    ${BEGIN_ID}
    ${END_ID}
    ${REPORT}
    EOF
    you can schedule this statspack_report in a crontab.
    thanks
    srinivas.

  • Generate RMAN backup Script using unix shell script

    Hello,
    Could somebody give me a unix shell script that would generate RMAN script based on some user defined parameters in a config file.
    e.g.
    rman.conf
    CHANNELS=4
    USE_CATALOG=Y
    DEVICE='sbt_tabe'
    etc.,
    many thanks,
    kam

    You can actually encapsulate the RMAN commands inside the shell script.
    However if you really want to create a seperate RMAN script file, you can use the unix shell's "echo" command to write set variables to a file.
    Thus, for example,
    echo "rman target / catalog rman/rmanpassword@crcat" > RMAN_Script.rmn
    echo "backup database plus archivelog" >> RMAN_Script.rmn
    echo "backup archivelog all" >> RMAN_Script.rmn
    creates RMAN_Script.rmn with 3 commands.

  • How to schedule a script in crontab for running every 45 mins.

    Hi All,
    Sorry for asking unix question in this forum.But nowhere i will get response like this forum.
    OS: HP-UX
    I want to schedule a DB script to run every 45 mins. In internet i found that we can
    put like */45 * * * * but it is not working in HP. Getting error " unexpected character found in line"
    Thanks,
    Siva.

    >
    Try this one by making following changes in crontab
    file by 'crontab -e, command
    45 * * * * /oracle/oracle/abc.shIt's not every 45min, but every hour (a quarter before the following hour).
    Nicolas.
    Don't know why it is starting by **, strange censor behaviour, it is just "It"
    Message was edited by:
    N. Gasparotto
    Oh, I understand. Previous line ended by sh, the following one start by it...
    Message was edited by:
    N. Gasparotto

  • Timer to generate on/off signal every 20 mins for 10 sec

    I need to create a simple timer. It comes on every 20 minutes for 10 seconds, then switches off until another 20 minutes has passed, and so it repeats itself. I want to open a valve with this every 20 mins for 10 secs, then close it. This is to work with a field point device that we have on our shelves.

    Here is a simple solution.
    Create a while loop, inside the while loop put a sequence in step 1 place a wait vi and set the value to 20 min (remember this input is in ms so 20 min = 1200000) in step two place the code to send the on signal (hardware output I assume) in the third step of the sequence place another wait for 10 seconds (10000 ms) and finally place the off sequence last. This solution is very processor friendly. If you just compair time stamps inside a loop, the loop will be continiously checking the time and your CPU use will max out. You can place an inherent wait in the loop but the responsivness (accuracy of your timming) will be reduced. The wait statment will pause your program until the timer (I believe it is linked to the OS interupt system) expires. This solution allows for multiple threads (loops) to run cuncurrently with little extra overhead. I have used timers to generate alarms in the past where the sequence after the time expiring fires an occurance to drive code in other loops. Hope this helps
    -Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • Can someone post apple script code to tell Safari to refresh every 5 min?

    Can someone post apple script code to tell Safari to refresh every 5 min?
    thanx in advance!

    save the script as an application and checkmark the "Stay Open" box
    -- start script
    on idle
    tell application "Safari"
    activate
    set doc_url to URL of document 1
    open location doc_url
    end tell
    return 15 --<change the number 15 to the number of seconds you want between each refresh
    end idle
    -- end script
    <br>
    Mac OS X (10.4.7)

  • Alerting user every 5 mins from system speaker using java script

    Hi Friends,
    I want to alert the user for every 5 mins from system speaker itself using Java Script.
    Please anybody can help me...
    Thanks and Regards
    Vijay Anand

    Java != JavaScriptYou are not asking in the appropriate forum. Go search the web for a JavaScript forum.

Maybe you are looking for

  • Total in REUSE_ALV_BLOCK_

    Hai friends, I am using the following function modules REUSE_ALV_BLOCK_LIST_INIT REUSE_ALV_BLOCK_LIST_APPEND REUSE_ALV_BLOCK_LIST_DISPLAY I want to give the total for the Quantity column alone. I am doing BOM explosion project. In this, i want the to

  • Cannot remove Disk Icons from Disk Images or External Drives from Desktop

    After years with PPCs, I just upgraded to an Intel Mac. I am now running into a funny problem. The majority of the time (although occasionally it works as it should), I am unable to eject disks. These include disk images from my internal hard drive,

  • Urgent help regarding Java regular expressions.

    hello everyone, I am trying to parse a html file which contains dyn.Img("http://www.boston.com/news/nation/articles/2007/06/21/bill_clinton_takes_bigger_campaign_role&h=306&w=410&sz=13&hl=en&start=43","","QFo9lqKeMR7uzM:","http://cache.boston.com/res

  • How to download photoshop cs2

    how i can download photoshop cs2 trial version

  • Multiple connection pools

    Hi, I have a requirement to build a report. The columns are scatterred in different connection pools. Copying the tables from different databases gives me error of OCI. What is the best way of doing this, i do not have the connection entries like use