Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 841
  • Last Modified:

Why a scheduled recurring Window task never finish running?

In Windows Task scheduler a batch file is scheduled to run everyday at 6am. The first day the job ran successfully (which kicked off some other processes) in < one minute. However the second day the status shows "running" persistently and the jobs that supposed to be kicked off by the batch file never got kicked off.

The batch job is scheduled to run every week day at 6am. It's now after 12 noon and it is sitll "running". Are there anything that I am missing?

The batch file is as follows:

@ECHO OFF
DEL C:\AT_Batch\at_spool.txt
sqlplus pinprd/pintst_pin05@xm_pintst  @"C:\AT_Batch\at_sql.sql"

Thanks.
0
HKBoyz
Asked:
HKBoyz
  • 3
  • 2
1 Solution
 
ECNSSMTCommented:
just a shot in the dark. as a test add RUN or CALL in front of the sql statement

(I forget which in NT was used to run an executable)

RUN sqlplus pinprd/pintst_pin05@xm_pintst  @"C:\AT_Batch\at_sql.sql"

and test

if the sql ran successfully and stopped.  I wonder if there is an open file issue with the BAT file that is preventing task scheduler from detecting a successful conclusion of the job.  I believe RUN (or CALL) should somehow permit the BAT file to close after the BAT is executed.  It has been a while.

Regards
0
 
HKBoyzAuthor Commented:
Hi

Thanks for the input. I tested both RUN and CALL. These are the results:

RUN:
After each successful scheduled run it did stop running. However, it didn't generate the output file as expected (ie. it didn't exec. the 3rd line in the batch file as listed below). It did delete the file, but no new file has been generated. (the at_sql.sql script will generate an output file if run successfully.

@ECHO OFF
DEL C:\AT_Batch\at_spool.txt
RUN sqlplus pinprd/pintst_pin05@xm_pintst  @"C:\AT_Batch\at_sql.sql"

CALL:
It worked exactly the same as if with out CALL in the third line. Its status remains "running" after first scheduled run. Therefore it never kick off the second or any subsequent scheduled run. (however first scheduled run was success and t did exec. the sql file and generated the output file).

@ECHO OFF
DEL C:\AT_Batch\at_spool.txt
CALL sqlplus pinprd/pintst_pin05@xm_pintst  @"C:\AT_Batch\at_sql.sql"

Any other hints??
0
 
ECNSSMTCommented:
Hi HKBoyz,

sounds like the CALL command was the way to go.  If I remember correctly when you execute a BAT file from an existing BAT file, there is issues of how the BAT file allocated memory for this.  But since the CALL didn't worked to the point of the original statement, it would be interesting to see what the sql statement houses.  I am guessing, but if you ran sqlplus pinprd/pintst_pin05@xm_pintst  @"C:\AT_Batch\at_sql.sql" from a command line, what happens?  Does it stay in sql after the command finishes? Does it stay in SQL?  If so what happenswhen you either add a "QUIT" or "EXIT" to the end of the sql job?

regards,
0
 
HKBoyzAuthor Commented:
Added "Exit" in the SQL file and now it's all working fine.
Thanks.
0
 
ECNSSMTCommented:
cool.  I've been busy the last few days with tech issues of my own. but I'm glad that worked out.

And thanks for the points.

Regards
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now