Capturing Users with running sql in shell script after every 10min

Hi All,
we have a strange prob. of database crash, therefore decided to check what users do when OS/DB crashes,
i need your input in RUNNING/SCHEDULING such a script which gathers all active users with running SQL and append in a logfile so that we are aware of what happened when DB/OS Crashed.
i can run this run a query from V$SESSION,V$SQL, and V$PROCESS but i need your input writing such a SHELL Script and scheduling can run by CRON.
Regards.

Here ya go.
(Assuming you want a script to run against one sid)
script:
#!/bin/ksh
# Set environment
. $HOME/.profile
export ORACLE_SID=your sid
sqlplus <<! > /some_report_file
/ as sysdba
sql you want to execute here*
exit
cron entry:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /your/script/name/here > /dev/null 2>&1

Similar Messages

  • How to generate an alert box with some message by Apple Script after every user login

    Hi,
    I am looking into an automation where whenever a user comes and does a login on his/her mac. It should pop an alert message to him.
    I want to achieve this in applescript.
    Is this possible?
    Thanks in advance for your suggestions and help!
    Abhishek

    Do you want it to run on any, unspecified user account? or specific users?
    If specific users, save the script as an application and save it in their Login Items.
    If you want all users then a hybrid AppleScript/shell script combo might be your best bet.
    Create a shell/AppleScript:
    #! /usr/bin/osascript
    tell application "Finder" to display dialog "welcome"
    Then create a launchd agent in
    /Library/LaunchAgents
    that will cause the script to load whenever any user logs in. Get yourself a copy of Lingon if you're not famiiar with creating launchd .plists

  • Please help to call oracle procedure with out paramter from shell script

    Hi
    I want to call a process with out parameter from shell script. I am calling process in shell script in below way
    function Process_loads {
    ( echo 'set serveroutput on size 1000000 arraysize 1'
    echo "set pagesize 0 term on verify off feedback off echo off"
    echo "BEGIN"
    echo " dbms_output.put_line('Before Calling The package'); "
    echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
    echo " dbms_output.put_line('After Calling The package'); "
    echo "EXCEPTION "
    echo " WHEN OTHERS THEN "
    echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
    echo " ROLLBACK;"
    echo "END;"
    echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
    Here $error_code is out paramter. All varaibles passed in process are declared with export command.
    When executing .sh it gives below error
    "sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
    Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
    Thanks in advance

    You can try this:
    From sql*plus
    SQL> ed
      1  create or replace procedure my_proc(p_id in int, p_result out int)
      2  as
      3  begin
      4  select 10 * p_id
      5  into p_result
      6  from dual;
      7* end my_proc;
    SQL> /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2  v_r int;
      3  begin
      4  my_proc(10,v_r);
      5  dbms_output.put_line(v_r);
      6  end;
      7  /
    100
    PL/SQL procedure successfully completed.
    from bash:
    testproc.sh:
    #!/bin/bash
    (echo 'set serveroutput on';
    echo 'declare';
    echo 'v_r int;';
    echo 'begin';
    echo 'my_proc(10,v_r);';
    echo 'dbms_output.put_line(v_r);'
    echo 'end;';
    echo '/';) | sqlplus -s u1/u1
    Console:
    oracle@mob-ubuntu:~$ chmod u+x testproc.sh
    oracle@mob-ubuntu:~$ ./testproc.sh
    100
    PL/SQL procedure successfully completed.With kind regards
    Krystian Zieja

  • Sql loader shell scripting

    Hi All,
    I need help on sql loader shell scripting basically since my input file is csv file will load into some target table say xx_90 along defining with control and data file. what where the data that goes into the bad file a segment of scripting that keep watching on badfile directory path if any bad file it finds it should move to a sperate database error table.
    Plz any sqlloader shellscripting experts can provide me the solution for this. Its a very urgent code i need to deliver I need the sample code for this your help is highy appreciated
    thanku
    sahana

    thanku..............when the load fails it moves to bad file script something like filewatcher it sees the data in the badfile and loads into the database error table........as i am basically businessobjects developer as for time being they have assinged me the task i did few manual loading on sql loader but i never have any experince on writing unix scripting i am quite worried to get this script done........
    can i use the samecode for the failed bad records into seperate external table......
    here i would change the path location and the rest goes as it isright............................i have the script for loading the datainto the targetsomething like this:
    sqlldr userid=ops$NGPTQMS/[email protected] \
    control=${evncpaq1/apps/cp/cm/r11.5.10/geae/gl/include/PAY0001_test.ctl} \
    data=${evncpaq1/data/infile/mon_gross_det.dat} \
    log=${evncpaq1/data/infile/mon_gross_det.log} \
    discard=${evncpaq1/data/infile/mon_gross_det.dis} \
    errors=999
    #bad=${BAD_FILE} \
    if [ $? -ne 0 ]; then
    echo "Error ! The sql loader call failed "
    exit 1
    fi
    IF any error is there in the script plz modify it and plz provide the complete code where to incorporate the code which you have written for bad file. Would be set it in seqence the steps so that i can run it in cron tab basically i have no other support for me to assist me on the job.......
    my dba has sent me the mail something like this:
    Please see the attached script to archive the source file once we are done with loading the data to the database. You already have the script for loading the data to the database. Please incorporate the attached script with your loading script. This script is generic and can be used to archive the bad file also once it has been loaded into the database (in case of any failures). This script send an email in case of any failures to the defined email distribution list. Right now the assumption is to run this through the cron. It we need to run this through the Appworx I will have to do some changes in the script. Also we will have to install the appworx agent on the server. Please let me if we need to need to run this through appworx I will create the appworx module for the same.
    and the archive script he sent is:
    . $HOME/.profile
    # Script to Archive SysLog files
    # This script accepts 2 parameters
    # - 1: Script Name          2: File Name
    # Created By : Pravin Darbare
    # Creation Date : 03/19/2008
    # Modified Date :
    # Modification History :
    echo "Starting SysLog_archiving Process"
    # Set Environmental Variables
    echo "Invoke Set Variable Script `date '+%H%M%S'`"
    # Set Local Script Variables
    #SCRIPT_NAME=$1
    SOURCE_DIR=$1
    FILE_NAME=$2
    # Zipping and Archive Source File
    echo "Zip Source file `date '+%H%M%S'`"
    #cp $LOAD_SRC_FILES/$SOURCE_DIR/$FILE_NAME $LOAD_SRC_FILES/syslog/Old_$FILE_NAME
    gzip /$SOURCE_DIR/$FILE_NAME
    check_rtn_status=$?
    if [ $check_rtn_status != 0 ]; then
    echo "Zipping source file Syslog process unsuccessfull"
    mailx -s "Zipping source file during Syslog unsuccessfull" $PR_PAGER_EMAIL_LIST </dev/null
    exit 1
    fi
    echo "Archive Source File `date '+%H%M%S'`"
    mv /$SOURCE_DIR/$FILE_NAME.gz /$SOURCE_DIR/archive/$FILE_NAME.gz$FILE_EXT
    check_rtn_status=$?
    if [ $check_rtn_status != 0 ]; then
    echo "Archiving source file during Syslog load process unsuccessfull"
    mailx -s "Archiving source file during Syslog load process unsuccessfull" $PR_PAGER_EMAIL_LIST </dev/null
    exit 1
    fi
    # example of calling file Syslog_archiving_Files.sh /apps/syslog/source_dir a.txt
    # example of calling file (Bad file) Syslog_archiving_Files.sh /apps/syslog/source_dir_bad a.txt
    # You need to have directory "archive" in both pathes .
    based on the complete detailed mail must having some view plz provide me something like exact code the rest path directories i will change it........
    for me its highly urgent to keep up my job
    Your support is highly appreciated
    Thanks&Regards
    sahana

  • Running a simple shell script

    Not being a regular user of terminal on OSX, I have managed to forget how to run a simple shell script. The purpose of the script is to rename a set of files contained in a specific directory. Here is a sample of the script I wrote some time back:
    mv product_22.jpg 080688614423.jpg
    This command repeats for each file I need to rename. My recollection is that I simply put the actual script text file in the same directory as the images to be renamed and drag the script file into a new terminal window and hit enter to run. When I try this however I receive the following error:
    ord2: Permission denied
    Can anyone help me out here? I'm running 10.2.8. I seem to beforgetting a critical step somewhere along the way.
    Thanks
      Mac OS X (10.2.x)  

    Have you set the execution bit for the script? When not, use: chmod 755 script.

  • Automatically run shell script after publishing?

    Is there any way to automatically run a  shell script  after publishing?
    I would like to do some postprocessing on the remote server.
    The remote server is not mobileme,  so a tool like iwebenhancer  will not work.
    I will appreciate all kinds of tips and tricks and suggestions.
    best regards, Gabriel.

    So the Detect Change is to detect a change in the web page that the code is embedded, right?
    The only workaround would be, if you can modify what's in the ChangeDetection window is to not automatically enter the page but put in a red note to enter the page you want to be notified about.
    So instead of this:
    You would have this:
    where the visitor would have to copy and past the URL into the field.  Obviously not automatic. But might work if you can modify what is said in the window and not have the page automatically be entered.

  • How to add responsibility to an user with an sql script

    Hi All,
    Apps:11.5.10.2
    DB:9.2.0.8
    how can we add a particular responsibilty to mutiple application user at a time with an sql query.
    Thanks
    Sunil

    Hey,
    Thanks for the posting on this. I have been working on this for the past couple of days and found the same "issue". The SQL is working, but the fnd_user_resp_groups 'view' at least in our version doesn't display the 'start_date, end_date, description' correctly. It seems to be hard coded to display:
    start_date = 01/JAN/00
    end_date = NULL
    description = NULL
    I found this out as I was trying to alter the table, but it then I realized it was a view. And if you look at the view details, it will show it is hardcoded.
    You should look at the user_resp_groups_all view. It displays what you have set.

  • Embed SQL in shell script

    I'm trying to embed sql statements in shell.
    I'm new to this..
    Can someone please pass some relevant document links on the web which demonstrates it?
    What I'm looking for is:
    1) How to pass variables from shell environment to sql
    2) How to pass values back to the shell from sql
    Example:
    Say, I want to run a concurrent request ( inside a shell script) . Then I want to check the status of this concurrent requests from FND_CONCURRENT_REQUESTS
    For which I have do a:
    #/bin/bash
    #Submit the request
    CONCSUB APPS/APPS SYSADMIN 'System Administrator' SYSADMIN CONCURRENT FND FNDSCURS >> /tmp/${TWO_TASK}request.log
    #Here, I pull out the value of request id from the log #in v_request_no
    v_request_no=`cat /tmp/${TWO_TASK}request.log | cut -d" " -f3`
    echo "Submitted request No: ${v_request_no}"
    Now, I want to check the status of this request, for which I want to embed the sql:
    select status_code from FND_CONCURRENT_REQUESTS where request_id=${v_request_id}
    How do I embed this?
    And later, I want to pass the value of "status_code" back to my shell and do some manipulation.
    How do I get the value ( of status_code) back in shell script?
    I did a quick hunt on the google to find a relevant doc. No luck yet, so I thought I'll post it here and then go back to some more hunting.
    Message was edited by:
    itzz.me

    Replying to myself instead of editing previous post. Confusing either way, hopefully I picked the less-confusing route.
    The second script snippet that I posted would work really well except for one tiny detail: exit codes have to be numeric. The status_code column in FND_CONCURRENT_REQUESTS is certainly not numeric. :-)
    Here's something that should work. I even checked it for syntax this time, because, well, it's really ugly. :-) Needless to say, you'll need to modify it slightly to plug into your script, since I hard-coded a requestid for purposes of illustration. Please note that the sqlplus command in the here document is enclosed in backticks, not single quotes:
    ----begin code snippet---
    #!/bin/bash
    v_request_id=2415616 #Just an example, sub your own value here
    status_code=`sqlplus -s apps/appspass<<EOF | grep Code | cut -f2 -d:
    select 'Code:' || status_code
    from fnd_concurrent_requests
    where request_id = $v_request_id;
    exit;
    EOF`
    echo "Status code is: $status_code"
    ----end code snippet-------
    If you can't pass in the apps password from the environment, and have to hard-code a password into the script (yecccchhh), I'd suggest setting up a read-only user with SELECT privileges on FND_CONCURRENT_REQUESTS, and running sqlplus as the read-only user instead of apps.

  • Running sql or perl script using DBMS_JOB

    Hi,
    Is there a way to run a sql or perl script using DBMS_JOB procedures? I have a perl script which checks out the table usage and emails the report to specific users. I want to run this script in a job scheduler, where I am using dbms_job to add the job. Please help. Any suggestions are greatly appreciated. Thanks.
    -Kristine

    You cannot run sql or perl scrips using DBMS_JOBS. You can run only Oracle procedures, functions, packages with DBMS_JOBS. They have to be stored in the database. You will have to create a Pro*C program that is listening on the pipe and push data to that pipe by using dbms_pipe. Then you can execute anything you want.

  • User defined workflow calling unix shell script

    Hi
    I have defined a workflow in OWB 10GR2 which calles a user defined object before calling the actual mapping.
    The user defined object calls a unix shell script which sets things right in the shell before the mapping can run.
    When executing the shell script from a unix shell myself it does exactly what I want
    However if I call the same script from workflow it does not recognize any of the commands not even internal shell commands like ls, touch.
    I've created a small test.sh script
    #! /bin/bash
    ls -l > listing.txt
    Created a flow with a user_defined object of which property is set:
    COMMAND.Value /home/oracle/test.sh
    If I then deploy and start the flow get the following:
    PF_WEB_00:TEST Success
    /home/oracle/test.sh: line 2: ls: command not found
    Anyone has any clue why this is or what I'm doing wrong?
    Geert

    Hi Lew,
    Thanks for the reply.
    This basically confirms what I've figured out so far.
    I noticed I was able to get my script running by using absolute paths everywhere, after which my only problem was it could not resolve the TNS.
    To bypass this I ended up copying all the path settings out of the .profile of my oracle user into my script after which the script ran fine.
    At least now I know for sure what's causing it and that by making my scripts a bit more extensive then usual I can do what I please :)
    Geert

  • Process Flow - User Defined object calling Unix Shell script not working

    Hi, I have a User Defined Object in a Process Flow with the following parameters :-
    Command: /usr/bin/ksh
    Parameter List:
    Result Code:
    Script: cd /shell_scripts
    ./dwh_get_datafile.sh param1 param2 param3
    Success Threshold: 0
    The script executes but it does not correctly interpret all the Unix commands within it e.g command such as FTP, DATE, GREP etc.
    In the job details I can see :-
    ./dwh_get_datafile.sh: date: not found
    ./dwh_get_datafile.sh: ftp: not found
    ./dwh_get_datafile.sh: grep: not found
    ./dwh_get_datafile.sh: rm: not found
    ./dwh_get_datafile.sh: ls: not found
    ./dwh_get_datafile.sh: awk: not found
    Anyone know what I have done wrong ?
    The script runs fine when run as a Unix script while logged into Telnet.
    Thanks.
    Paul

    The shell script is executed by the oracle user in the unix environment so make sure that the directorie where you can find the unix commands exists in the path for the oracle user in .profile as you can se in my example below.
    PATH=$PATH:$ORACLE_HOME/bin:$OWBHOME/bin:/ASW/ora_script:/local/bstat:/usr/bin:/opt/bin:/usr/local/bin; export PATH
    /JZ

  • PL/SQL using Shell Script

    Hi,
    I want to study in details about how to use shell script in pl/sql codes. Can any one suggest some useful link on the same.
    Nordik

    smon wrote:
    BluShadow wrote:
    miriam_omaha wrote:
    If you mean execute a shell script from a procedure, there are ways, not easy ways, to execute a shell script - try this thread on that topic:Not easy?
    What's not easy about setting up a job using DBMS_SCHEDULER which can directly call any executable at the operating system level?that doesn't meet the requirement, it's about executing host commands from within plsql.Which you can do with DBMS_SCHEDULER by creating a job to execute straight away. DBMS_SCHEDULER can execute operating system commands...
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#i1010013
    >
    'EXECUTABLE'
    This specifies that the program is external to the database. External programs implies anything that can be executed from the operating system's command line. AnyData arguments are not supported with job or program type EXECUTABLE.

  • Passing variable from sql to shell script

    Usually we can pass arguments from shell script to the sql that us called inside the shell script. But I also want to do the reverse. I have the location of my backup path in a table. I want to run the rman script (shell), read this parameter from the table and use this to construct the "format" path in rman. Anyone has any ideas about this. Thanks.

    To achieve getting the modified value from the table everytime the job runs, I encapsulated this in another job.
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB(
    JOB_NAME           => 'TEST_LOGS_MAIN',
    JOB_TYPE             => 'PLSQL_BLOCK',
    JOB_ACTION          => 'declare
    v_aname varchar2(32);
    begin
    select aname into v_aname from attr where attrid = 3;
    DBMS_SCHEDULER.CREATE_JOB(
    JOB_NAME        => ''TEST_LOGS'',
    JOB_TYPE        => ''EXECUTABLE'',
    JOB_ACTION      => ''/opt/sql/testy.sh'',
    number_of_arguments => 1,
    COMMENTS        => ''TEST'');
    dbms_scheduler.set_job_argument_value(''TEST_LOGS'',1,v_aname);
    dbms_scheduler.enable(''TEST_LOGS'');
    end;',
    REPEAT_INTERVAL => 'FREQ=MINUTELY',
    ENABLED           => TRUE);
    END;
    /

  • Calling sql through shell script

    How do i call a sql file through shell script in unix ?

    Rahul India wrote:
    export ORACLE_HOME=$ORACLE_BASE/product/10g
    cd $ORACLE_HOME
    set `sqlplus -s <SCHEMA_NAME>/<SCHEMA_PASSWORD> <<EOF
    @r_100.sql
    exit;   
    EOF`THIS SCRIPT IS OK?You'll also need to set ORACLE_SID
    And I don't know why everyone is putting the reference to sqlplus inside a "set" valuation, nor why they are putting the reference to the script in a redirected input stream. All you need is
    sqlplus -s user/password  @r_100.sqlAnd to insure the invironment is correctly set:
    export ORACLE_SID=whatever
    export ORAENV_ASK=NO
    . oraenv
    unset ORAENV_ASK=NO
    sqlplus -s user/password  @r_100.sql

  • Sample shell script - to run procedures and shell script

    Hi ,
    I would like run some procedures in one shell script which passing parameters as username/password@dbname.
    1. Execute proce1
    2.Execute proce3
    3.Execute proc4
    Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.I would appreciate your help.
    Regards,
    Clark

    user10818198 wrote:
    I would like run some procedures in one shell script which passing parameters as username/password@dbname.
    1. Execute proce1
    2.Execute proce3
    3.Execute proc4
    At a very basic level, based on the information you have provided, your shell script would be something like this:
    sqlplus /nolog <<EOF
    connect username/password@dbname
    exec proce1;
    exec proce2;
    exec proce3;
    exit
    EOFBesides this, you could:
    (1) Add the shebang at the top, to specify the shell you are using, e.g. #!/bin/ksh for the Korn shell etc.
    (2) Ensure that "sqlplus" is recognized by the shell, by maybe running an "ora_env.sh" script that sets Oracle parameters. More likely, if you are using this Unix account for interaction with Oracle, then you may want to add the Oracle parameter information in your .profile or .bash_profile or .csh_profile etc. in the home directory.
    (3) Run a few sqlplus commands right before calling those stored procedures, if needed. For example, if you want to exit from sqlplus (and Oracle) if an error occurs while executing any procedure, then add this -
    whenever sqlerror exit 1Thus your script becomes:
    #!/bin/ksh
    # Ensure that Oracle parameters are set by this point
    sqlplus /nolog <<EOF
    connect username/password@dbname
    whenever sqlerror exit 1
    exec proce1;
    exec proce2;
    exec proce3;
    exit
    EOF(There are other settings as well; it really depends on your requirements.)
    Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.
    How to create a shell script ? Well,
    (1) Save the commands shown above in a file, using your favorite text editor. Name the file "my_script.sh" or "<a_better_name>.sh" etc. (or maybe ".ksh" for the Korn shell - it's just a best practice, the shell doesn't really care.)
    (2) Make your script executable, like so -
    $ chmod 744 myscript.sh(3) And then execute it -
    $ ./myscript.sh- You could also execute the script in the current shell (as against a child shell) by doing this after Step (1):
    $ . myscript.shHope that helps.
    If there are specific questions, then post them here.
    isotope

Maybe you are looking for

  • OfficeJet 7500 won't print via WiFi anymore even though pings are successful

    This is a new OfficeJet 7500 All-in-One that I have been trying to get set up over the weekend but have run into problems. First here is the system data: From the EWS printer information page: Product name: OfficeJet 7500 E910 Product Model Number: C

  • Horizontal Scroll Bar in Power Pivot?

    Good Afternoon, I have recently installed PowerPivot and began importing my T-SQL queries into it, unfortunately for queries with a large number of columns, I am unable to see a horizontal scroll bar, although I do have a vertical scrollbar.  I can m

  • Struggling to have two document type attributes in the same notification

    Hi All, I need some help. I am working with Oracle Time and Labor, and am trying to get two document type attributes to play nice in the same notification message body. One documentation type attribute is made available to me. Here is its attribute v

  • SD card reader in DV5000 won't work in Windows 7. Can't find a driver to reload

    I have an   HP Pavilion dv5000 (EZ415UA#ABA) which I upgraded to Windows 7 when I replaced a dead hard drive.  Several of the onboard hardward devices quit working; among them was the multicard reader which I now need to read SD and MicroSD card (wit

  • 7342 too slow on loading

    HI I use 7342, it seems too slow to load parametres to the card between 20 ms and 40 ms : ( i have used canalyzer to check the time with 2 frames like below) CANTx_CVI_CMF();// can frame                              // Load motion parameters to the F