Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 SQL Agent CmdExec foreground vs. background

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-09 : 10:34:28
Dave writes "Does anybody know how to change the way CmdExec runs a program as either in foreground or background? I have seen SQL Agent do it two different ways so strongly believe there is a setting somewhere to control how it behaves.

What I mean by two different ways is as follows:

1. Create a job & (cmdexec) step from sql agent to simply launch notepad.exe.

In one instance of sql I have seen it actually launch the program in foreground and the job will continue executing until you simply close notepad. (Notepad is listed as both a running application and a process from task manager.)

In another instance of sql I have seen it only launch notepad.exe in background and you can only see or terminate the thread by opening task manager. (Notepad is only listed as a process from task manager and not as an application.)

Could this perhaps be a setting upon intial installation of sql-server or possibly an operating system setting?

Any help on this would be greatly appreciated."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-05-09 : 10:40:17
Well, for one thing, you shouldn't even be running Notepad from a SQL job. The same applies to any program that requires user intervention. If the machine is unattended, the app will just sit there, possibly eating many CPU cycles, possibly even blocking other processes from running, but certainly not doing anything useful.

If you are using command-line apps like bcp or dtsrun, these will terminate upon completion or an error, and are safe to run as cmdexec steps. I wouldn't focus too much on trying to find a way to run things as background or foreground, but instead make sure that apps will terminate properly if called from a SQL job.

Go to Top of Page

efelito
Constraint Violating Yak Guru

478 Posts

Posted - 2002-05-09 : 10:59:42
I don't think this is something you can set. It launches under the assigned security context. It may have poped up notepad if you were logged into the server with the same account that the cmdexec was running under. This is not the norm, as Rob said, you don't want to run anything in a job that requires user intervention.

Jeff Banschbach
Consultant, MCDBA
Go to Top of Page
   

- Advertisement -