How to stop running a scheduled batch file?

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 day at 6am. It's now after 12 noon and it is sitll "running". I tried to add an "exit" line at the end but it didn't work. Is there anything that I am missing?

The batch file is as follows:

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

Who is Participating?

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

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.


I would add the word CALL in front of this line: sqlplus pinprd/pintst_pin05@xm_pintst  @"C:\AT_Batch\at_sql.sql" so that a response is returned to the batch file so that it can close out.
HKBoyzAuthor Commented:
I did try that but got the result (ie. status keeps "running" forever).
HKBoyzAuthor Commented:
I mean I got the same result with "CALL".
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Steve KnightIT ConsultancyCommented:
Is the SQLPLUS process still running ... check task manager process list and kill it.

at the end of the batch file.
HKBoyzAuthor Commented:
did try both and got the same result. This may not be the problem of the batch file. I have "exit" in the batch file and i could see the dos window pop uo when batch file is being executed. When finished the dos window goes away, but the batch status is still "running".

Would it be the Windows Task Scheduler which keeps the batch file running?
perhaps the batchfile stops at the line where the file is deleted because it is asking for confirmation but you cannot see it ;
the first time went ok because the file did not exist (just guessing)
Try adding /Y after the delete command to avoid confirmation dialog
Steve KnightIT ConsultancyCommented:
So is the SQLPLUS process till running or not?  Perhaps Task Scheduler sees that a 'child' process is still running?
What happens when you launch it manually?

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
HKBoyzAuthor Commented:
Added "Exit" at the end of the SQL file (not the batch file) and it takes care of it. Once the SQL was executed the batch file also stopped running.
Thanks everyone.
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
Windows OS

From novice to tech pro — start learning today.