task in task scheduler failing when executing batch file - batch-file

I have a task set up on a windows server 2008 R2. This task is setup in the task scehduler to execute a batch file that backs up a mongo database, every 4 hours. I have it set up the same on 2 servers.
On 1 server it runs fine.
On the other, I get this error logged in the history and it doesn't execute.
Task Scheduler failed to start "\Backup MongoDb" task for user "*****". Additional Data: Error Value: 2147750687.
I am lost for ideas what the issue may be. Anyone got any ideas?

My workaround is to call a .BAT file from the Task Scheduler.
This batch file then calls the PowerShell script file:
powershell c:\dir1\AutoPopulate.ps1
Seems to work.

I have run into this a few times. Check the last run result on the task. If it says another instance is already running, right-click on the task and click "End." Then after it ends the task it should start again correctly the next time. You can also right click and choose "Run" to run it immediately.

Check the Security options of your Task.
Make sure, the option Run whether user is logged on or not is selected.

Related

WinSCP script works fine manually, but failes when executed by SQL Server Agent Job

I have a WinSCP script that SFTPs a file from a remote server to a local directory. The script works fine when I execute it from the command line, but when I try to execute it as a command step in a SQL Server Agent job, the job fails. All the history tells me is:
Executed as user: NT Service\SQLSERVERAGENT. The step did not generate any output. Process Exit Code 1. The step failed.
which could mean anything. I've tried to break the problem down to its core by stripping everything out of the script except an exit statement. It still fails, so I know the issue is not in the script. Any thoughts?
Posting in case anyone else runs into this problem. The WinSCP FAQ has a little section on these kinds of problems, but missed one ridiculously simple possibility: does the job have access to the script being executed?
Regardless of who created the script, the command will be executed by the SQLSERVERAGENT account. If you're like me, you keep your scripts under your user account's home directory, which SQLSERVERAGENT doesn't have access to. Move the script to a directory it can read and see if that fixes it for you. I used the Users\Public directory.

Execute process task fails to execute Rust script in job

I have written a small Rust script for an import job. I added the script execution into the SSIS package through the Execute process task and set the correct working directory. Using the debugger, the script works without a problem, as it does when executed normally, e.g. through cmd or PowerShell.
When I start the job in SSMS as an Agent Job, the package fails with
The process exit code was "-1073741515" while the expected was "0".
What I tried
Replacing the script with a very basic Rust script that just writes one single line to a file in the working directory to exclude the possibility that the script somehow panics, but still nothing.
The script is compiled with the i686-pc-windows-msvc toolchain. With 64bit the script does not work at all on the server.
Permissions look okay for the executing and the working directory. Full control for both folders.
Since execution works on the server I think this should most likely be a permissions issue but I can't for the life of me not figure out what is wrong.
Okay the problem was indeed with the default SQL Server Service Agent-account that ran the job. If I run the job with a Proxy-account it runs fine.
I'll have to look into the configuration of the Service Agent but until then, Proxy account it is.

SSIS in SQL 2014 running an Execute Process Task failing

Running a Cmd.exe inside an ETL Process Task and it's failing with Exit code 1.
If I run the command as the same user I'm running the SQL Agent job as outside of the ETL it's running fine and giving Exit code 0.
I've seen some DCOM errors in Event Viewer and Ive taken steps to give permissions to the user I'm running the ETL through the SQL Agent Job for. However it's still failing.
Are there other things I should check about running a CMD command across servers as a specific user?
Just to say this was a permission issue ultimately for it to write a file inside the Default folder. It wasn't manifesting as such until I dumped out the Log a little more. I had to make the user I was running the agent job to be a part of the Administrators group on the SSIS server to allow the process to work.

Windows Server 2008 R2 Task Scheduler: Task does not repeat

i have created a task with the Task Scheduler on my Windows 2008 R2 Sever.
It opens a .bat file. This bat has no errors and works fine.
If I start the task (i.e. by clicking on run) it executes the bat file.
From now it should repeat every x minutes (currently set to 1 minute) but it does not.
I tried a lot and changed almost every property but it still does not repeat executing my bat file.
I have read different questions and answers but nothing worked.
Has anyone an idea what I am doing wrong?
Thanks!
Björn
It seems like the error was about the "begin"-property of the trigger. It was set to "When task is created/modified".
I changed it to a one time event.
Things work fine now.

Access macro did not run on the server when the database opened by a scheduled job

I have a scheduled job on the server. The job is to run a batch file at night when I am logged off. It simply opens an Access database and runs a macro. I have used /x to do this, and all references to files are UNC, not via mapped drives.
When I run the batch file by double clicking on it, it runs and finishes smoothly, however the scheduled job does not seems to be working. It opens the database and leaves it open until next morning and the macro is not executed. I have to clear MSACCESS.EXE from the Task Manager next morning.
I have tried with VBScript and found same result.
Does anyone have a clue?

Resources