Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2004
    Location
    VA
    Posts
    35

    Unanswered: dbms_scheduler: How can I change the default user and shell running the scripts?

    We are running Oracle 10.2.0.3 on Solaris 10. I have a strong background with third party enterprise job schedulers (UC4 and CA AutoSys), and I am trying to avoid a big ticket purchase by implementing Oracle Scheduler at a customer site. I need to run various shell scripts under different Unix users’ credentials, and I need to save the output from the scripts to log files on the Operating System for potential later review.

    Here is a sample test script that I am running:

    #!/usr/bin/ksh

    set +x # Make sure that command echo is turned off (to clean up output)
    ScriptName=$(basename $0) # Equivalent shorthand code is: ${0##*/}
    ScriptPath=$0 # $0 gets set by the preceeding $(basename $0) syntax

    date +"%n%D %T %A%n"

    ServerName=$(hostname) # Unix host name
    UserName=$USER # Unix user name ($LOGNAME holds the same information)
    StartingDirectory=$(pwd) # Starting Unix directory

    echo "ServerName=$ServerName"
    echo "UserName=$UserName"
    echo "LOGNAME=$LOGNAME"
    echo "StartingDirectory=$StartingDirectory"
    echo "ScriptName=$ScriptName"
    echo "ScriptPath=$ScriptPath"
    echo "SHELL=$SHELL" # Unix shell name

    Here is the Oracle PL/SQL syntax I am using to launch the job:

    begin
    dbms_scheduler.create_job(
    job_name => 'jps_test_executable',
    job_type => 'EXECUTABLE',
    job_action => '/usr/bin/ksh',
    number_of_arguments => 2
    );

    dbms_scheduler.set_job_argument_value (
    job_name => 'jps_test_executable',
    argument_position => 1,
    argument_value => '-c'
    );

    dbms_scheduler.set_job_argument_value (
    job_name => 'jps_test_executable',
    argument_position => 2,
    argument_value => './tmp/OracleScheduler/display_shell.ksh drtest incr1>/tmp/OracleScheduler/display_shell.log'
    );

    dbms_scheduler.enable('jps_test_executable');
    end;
    /

    This job runs, but the resulting login credentials are unexpected. Here is the output from the job:

    12/11/07 14:10:33 Tuesday

    ServerName=server1
    UserName=
    LOGNAME=
    StartingDirectory=/
    ScriptName=display_shell.ksh
    ScriptPath=./tmp/OracleScheduler/display_shell.ksh
    SHELL=/bin/sh

    Can anyone help me resolve these issues?

    1. The Operating System username (i.e., $USER and $LOGNAME) returns as blank or null (I’m not sure which). How can I specify which Operating System user will run the job?
    2. The shell appears to be Bourne, even when I specifically execute a “ksh” command in a variant of the script. How can I force the job to run under the Korn shell?


    Any and all help is appreciated!

    J

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    post output from
    env | sort
    immediately after logging onto the system
    Last edited by anacedent; 12-11-07 at 16:29.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Scheduled jobs run as the same user that is running the oracle databse, on unix typically the oracle user. The startup scripts are NOT run. Any environmental settings must be setup in the script.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  4. #4
    Join Date
    Dec 2004
    Location
    VA
    Posts
    35
    Quote Originally Posted by anacedent
    post output from
    env | sort
    immediately after logging onto the system
    PWD=/
    _=/usr/bin/env

  5. #5
    Join Date
    Dec 2004
    Location
    VA
    Posts
    35
    Quote Originally Posted by beilstwh
    Scheduled jobs run as the same user that is running the oracle databse, on unix typically the oracle user.
    Are you sure? If that is the case, shouldn't the log file be owned by the Unix oracle account, rather than "nobody?" Also, the job cannot read or write any files in the oracle account's $HOME directory tree.

    ls -l display_shell.log
    -rw-rw-rw- 1 nobody nobody 225 Dec 12 07:14 display_shell.log


    Quote Originally Posted by shew01
    StartingDirectory=/
    Also, if the Unix Oracle account is running the script, I would expect the default directory to be /usr/oracle instead of /. Am I missing something here?

    Quote Originally Posted by beilstwh
    The startup scripts are NOT run. Any environmental settings must be setup in the script.
    Yes, I would agree with this. I have seen similar issues with other schedulers.

    Any idea on how to verify which Unix account is running the script? (The Unix oracle account is running Oracle, and presumably the scheduler, but that doesn’t appear to match the output that I am getting.)
    Last edited by shew01; 12-12-07 at 09:03.

  6. #6
    Join Date
    May 2006
    Posts
    132
    The scheduler will run as nobody by default. You should configure the file $ORACLE_HOME/rdbms/admin/externaljob.ora to include the user oracle and it's corresponding group.

  7. #7
    Join Date
    Dec 2004
    Location
    VA
    Posts
    35
    Thank youuuuuuu! I'll check it out.

  8. #8
    Join Date
    Dec 2004
    Location
    VA
    Posts
    35
    Yes! This finally works. By the way, Oracle MetaLink Note 391820.1 has more detail.

    Thanks again "ebrian."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •