how to schedule a job?

Hi Expert,
I need to schedule a job.
the job is a select query which is used to unlock the statistics for paricular schema.
create.sql
spool /home/oracle/1.sql

select 'set head off' from dual;
select 'set linesize 65' from dual;
select 'set pages 0' from dual;
select 'spool /home/oracle/Unlock_Table_Stats.log' from dual;

select replace('exec dbms_stats.unlock_table_stats(~SIEBEL~,~'||table_name||'~);',CHR(126),chr(39)) from all_tables where owner = '****;
select 'exit' from dual;
spool off

spool /home/oracle/2.sql
select 'set head off' from dual;
select 'set linesize 210' from dual;
select 'set pages 0' from dual;
select 'spool /home/oracle/Generate_Table_Stats.log' from dual;

select replace('exec dbms_stats.gather_table_stats(ownname => ~*****~, tabname => ~'||table_name||'~, method_opt => ~FOR ALL COLUMNS SIZE AUTO~, granularity => ~ALL~, cascade => TRUE, degree => DBMS_STATS.DEFAULT_DEGREE);',CHR(126),chr(39)) from all_tables where owner = 'SIEBEL' order by num_rows desc;
select 'exit' from dual;
spool off

its spools the o/p in 1.sql and 2.sql and again we have to run the 1.sql and 2.sql.

Client want us to schedule the above scrips which must run every weekend.

Please let me know how do i schedule this job which should run on every weekend.

the above script file name is create1.sql
which spool 2 file create1 and create2 .sql
which i have to run again.

exit
danieshAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BawerCommented:
you can use windows task schedular for this job,, although oralce task sch.. may be good option but in such case i will recommond you use windows task sch... create a batch file, where via the SQLPLUS the script is executed  as @create.sql.

batch file

cd\
sqplus "/ as sysdba"
@create.sql

define time as once the 1script is executed ,, execute another script within 20 min...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
danieshAuthor Commented:
we are using linux server.
slightwv (䄆 Netminder) Commented:
Create a simple shell script and put it in cron:

#/bin/sh
rm /home/oracle/1.sql
rm /home/oracle/2.sql

sqlplus -s /nolog << EOF
conn username/password
@create.sql
@/home/oracle/1.sql
@/home/oracle/2.sql
EOF


Any reason you went down this path instead of a stored procedure and DBMS_SCHEDULER?  This way everything is contained inside the database.

Any reason for executing this at the TABLE level instead of SCHEMA level?  Then it's just two calls w/o the loop and individual calls.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

danieshAuthor Commented:
Can you advice me how can i set using dbms_schedukler
siobiCommented:
refer to this. http://psoug.org/reference/dbms_job.html

is call DBMS_JOB

eg:
1) assume you had a procudure created, then you just need to run
-- To run everynight at midnight starting tonight
exec dbms_job.submit(:v_JobNo, 'proc1;', TRUNC(SYSDATE)+1, 'TRUNC(SYSDATE)+1');


siobiCommented:
thanks
DavidSenior Oracle Database AdministratorCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.