September 15, 2016 at 2:54 pm
I'm having a problem running a job that calls CmdExec. The step output is just this:
Date9/15/2016 4:31:52 PM
LogJob History (TheJobName)
Step ID1
ServerTheServer
Job NameTheJobName
Step NameTheStepName
Duration00:00:00
Sql Severity0
Sql Message ID0
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted0
Message
Executed as user: TheSqlAgentUser. The step failed.
I know that the path is correct because if I change it, then it tells me that it can't find the file. The cmdexec looks like this:
\\share\path\TheProgram.exe
The program is a console application developed in .NET. The console application runs successfully if started outside SQL Agent. This program is replacing an existing program (which was also a console application) that had been running via the same job successfully. While the program displays data to the console (data which is also logged elsewhere), it does not require any input from the console. I don't care if the console is visible. It's a long-running application, so it should leave the job in a running state, not in an immediate failure state.
To add complication to this scenario, the server on which this is running was recently replaced. All software was reinstalled and the database was restored. So it's possible that any special configuration that was done to allow SQL Agent to run this job was lost. The knowledge of that configuration, if any, was lost years ago when the initial developer left.
The application should be logging, but it appears the error, whatever it is, occurs before the app starts. The very first thing this application does in main is to log that it's been started.
If only I had an error message to work with...
Ideas?
September 15, 2016 at 2:58 pm
Could be the return code that the application is sending. Look to see what's being returned, and what the step is handling as successful step output.
September 21, 2016 at 8:23 am
Just to close this thread... the return code is void (.NET programs can return void from main). I don't know what's actually returned in that case, but it doesn't matter. The program is supposed to run until the job is aborted. Yes, this program should be a Windows service, but for historical and time-constraint reasons, it's not. Most likely it was encountering some sort of error while trying to load itself into memory, but that error was not being reported anywhere and I was frustrated about how I would go about fixing an unknown error.
Anyway, the server was restarted overnight and the program started working when called from the job. I have no idea why it required a restart. But, I'll call that solved.
September 28, 2016 at 2:54 pm
I had this problem occur again on a different server. This time, I found the error message. The message is in the Application Error Log in Windows Event Viewer. I think this should have occurred to me in the first place. But if someone finds this thread and has the same problem... this is the real solution.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply