Task Scheduler failed to start - scheduled-tasks

Last weekend I came across Launch Failure in the windows task scheduler. The details are as below -
> Log Name: Microsoft-Windows-TaskScheduler/Operational Source:
> Microsoft-Windows-TaskScheduler Date: 6/24/2012 1:14:16 PM
> Event ID: 101 Task Category: Task Start Failed Level:
> Error Keywords: (1) User: SYSTEM Computer: Some
> Computer Name Description: Task Scheduler failed to start "some file
> path" task for user "author". Additional Data: Error Value:
> 2147549186. Event Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
> <System>
> <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{DE7B24EA-73C8-4A09-985D-5BDADCFA9017}" />
> <EventID>101</EventID>
> <Version>0</Version>
> <Level>2</Level>
> <Task>101</Task>
> <Opcode>101</Opcode>
> <Keywords>0x8000000000000001</Keywords>
> <TimeCreated SystemTime="2012-06-24T20:14:16.003204300Z" />
> <EventRecordID>2091795</EventRecordID>
> <Correlation />
> <Execution ProcessID="936" ThreadID="812" />
> <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel>
> <Computer>Some Computer Name</Computer>
> <Security UserID="" /> </System> <EventData Name="TaskStartFailedEvent">
> <Data Name="TaskName">some file path</Data>
> <Data Name="UserContext">author</Data>
> <Data Name="ResultCode">2147549186</Data> </EventData> </Event>
First, what is the meaning of error code "Error Value: 2147549186".
Second, what could be the reason for this issue.
Finally, what is the resolution for the issue.
My heartiest thanks in advance for the replies :)

So I just had the same issue on my server after changing the password for the account that the tasks were run under.
To solve I made a change to the task settings that required me to re-enter the account password.

I had the same issue with the same error code. You can have a try on change following.
=== quote start ===
in task scheduler, click on the scheduled job properties >>> then settings
in the last listed option:
"if the task is already running, the following rule appplies:"
select "stop the existing instance" from the drop down list.
http://answers.microsoft.com/en-us/windows/forum/windows_vista-windows_programs/task-scheduler-failed-to-start-additional-data/96994b77-d690-4403-8b51-4e1d0ae998e1

Related

Rundeck - flow execution with error handler

Default error handler works in a way, if any job sequence does not end with the non-zero status it went into error handler flow.
I wanted to implement the flow, if the API endpoint returns 204, I need to perform some dependent operation.
I was thinking of doing it using an error handler but how I can deal with the return status 204 as it just handles non-zero status flow in the error handler.
On Rundeck Enterprise you can do it using the Ruleset Strategy (for example, catch the exit code and put it on a data option to decides if runs or not another job), take a look at this.
On the Community version you can do it scripting, manage the behavior on an script step in the following way (on my example i want to detect only the 127 error, defined on an option):
A job definition example:
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='code_to_catch' value='127' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>ab58e8e3-78f8-4a60-b6fc-4ad1167aa3a4</id>
<loglevel>INFO</loglevel>
<name>HelloWorld</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<fileExtension>.sh</fileExtension>
<script><![CDATA[date-foo-bar # intentional error
mycode=$(printf '%d\n' $?)
case $mycode in
#option.code_to_catch#)
echo "Executing actions for #option.code_to_catch# error"
## also, you can run any job using RD-CLI (https://rundeck.github.io/rundeck-cli/)
## or Rundeck API (https://docs.rundeck.com/docs/api/rundeck-api.html)
;;
0)
echo "all ok!"
exit 0
;;
esac
]]></script>
<scriptargs />
<scriptinterpreter>/bin/bash</scriptinterpreter>
</command>
</sequence>
<uuid>ab58e8e3-78f8-4a60-b6fc-4ad1167aa3a4</uuid>
</job>
</joblist>
As you see, you can use the inline script to caught the error code and later run another job using RD-CLI if you like.

How can I run a job on Rundeck for each user in the list?

I want to create a scheduled job on Rundeck. Rundeck Job runs the script that does some staff for a single user I have in my list.
So job has an input parameter - username. I need to run that job for all users in my list, but not to process it in one job execution. I need a separate job execution for each user.
Providing an example to make it more clear:
For instance, I have 3 users: user1, user2, user3.
I have a job that does some processing for that users and running it with parameter (unsername).
I need to create a scheduled job that will be run for each user.
1. Running job with user1 parameter
2. Running job with user2 parameter
3. Running job with user3 parameter
Is there anyway to do that?
You can design a workflow with a list option to use on any step (like command, inline-script or script), I did an example with a list option (users) and example inline-script that do some action for each user, the job is scheduled.
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='users' required='true' value='alice,bob,charlie,david' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>e62a25a0-b67c-4bb7-8721-c96b7e4cb9f5</id>
<loglevel>INFO</loglevel>
<name>JobEXAMPLE</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<schedule>
<month month='*' />
<time hour='12' minute='0' seconds='0' />
<weekday day='*' />
<year year='*' />
</schedule>
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<fileExtension>.sh</fileExtension>
<script><![CDATA[#!/bin/bash
myusers=#option.users#
Field_Separator=$IFS
# set comma as the internal field separator for the string list
IFS=,
for value in $myusers;
do
echo "action for $value"
done
IFS=$Field_Separator]]></script>
<scriptargs />
<scriptinterpreter>/bin/bash</scriptinterpreter>
</command>
</sequence>
<uuid>e62a25a0-b67c-4bb7-8721-c96b7e4cb9f5</uuid>
</job>
</joblist>
Here the result.
Maybe this interest you. Also, data values work in this case.

How to redirect nant build errors to 'catch' section?

I need to build my application in 'try-catch' section of nant config file, like this:
<trycatch>
<try>
<echo message="Start building MyApplication.."/>
<call target="BuildApp"/>
</try>
<catch>
<echo message="Build MyApp.sln is failed"/>
<fail/>
</catch>
</trycatch>
When build is failed it only shows the message: "Build MyApp.sln is failed", without any detailed information why it failed. How can I redirect build errors to 'catch' section and see the reason of failing?
You need to add the property attribute to the catch tag:
<trycatch>
<try>
<echo message="Start building MyApplication.."/>
<call target="BuildApp"/>
</try>
<catch property="failure.message">
<echo message="Build MyApp.sln is failed"/>
<echo message="Failure message: ${failure.message}"/>
<fail />
</catch>
</trycatch>
You could also forward the failure message via <fail message="${failure.message}" />.

Running NUnit via NCover with NANT

My unit tests are being executed and reports written, however the coverage reports are empty. This is the Nant task I'm using:
<target name="unitTests">
<foreach item="File" property="filename">
<in>
<items>
<include name="**\UnitTestBinaries\*.UnitTests.*.dll"></include>
</items>
</in>
<do>
<exec program="${ncover-console}"
workingdir="${path::get-directory-name(filename)}"
commandline=""${nunit-console}" ${filename} /xml:${project::get-base-directory()}\_nunit_${path::get-file-name-without-extension(filename)}.xml /nologo //x ${project::get-base-directory()}\_ncover_${path::get-file-name-without-extension(filename)}.xml"
failonerror="true"
verbose="true"/>
</do>
</foreach>
</target>
Any ideas why I'm not getting coverage data? Is there any easier way to achieve this step?
Thanks for any help.
Edit:
This is an example output file:
<!-- saved from NCover 3.0 Export url='http://www.ncover.com/' -->
<coverage profilerVersion="3.3.0.6070" driverVersion="3.3.0" exportversion="3" viewdisplayname="" startTime="2011-10-31T23:27:33.3688015Z" measureTime="2011-10-31T23:27:36.1420615Z" projectName="" buildid="d3a76074-bb16-4677-8273-91c7b6552066" coveragenodeid="0" failed="false" satisfactorybranchthreshold="95" satisfactorycoveragethreshold="95" satisfactorycyclomaticcomplexitythreshold="20" satisfactoryfunctionthreshold="80" satisfactoryunvisitedsequencepoints="10" uiviewtype="TreeView" viewguid="C:\_documents\CI\_ncover_XTFL.UnitTests.Core.xml" viewfilterstyle="None" viewreportstyle="SequencePointCoveragePercentage" viewsortstyle="Name">
<rebasedpaths />
<filters />
<documents>
<doc id="0" excluded="false" url="None" cs="" csa="00000000-0000-0000-0000-000000000000" om="0" nid="0" />
</documents>
</coverage>
Edit II:
This is a sample of the buildlog output (edited for security):
<task name="ncover">
<message level="Info"><![CDATA[Command: C:\Program Files\NUnit 2.5.10\bin\net-2.0\nunit-console.exe]]></message>
<message level="Info"><![CDATA[Command Args: C:\_documents\CI\Working\UnitTestBinaries\XTFL.UnitTests.Workflow.dll /xml:C:\_documents\CI\_nunit_XTFL.UnitTests.Workflow.xml /nologo /noshadow]]></message>
<message level="Info"><![CDATA[Working Directory:]]></message>
<message level="Info"><![CDATA[Assemblies: (All Loaded Assemblies)]]></message>
<message level="Info"><![CDATA[******************* Program Output *******************]]></message>
<message level="Info"><![CDATA[ProcessModel: Default DomainUsage: Single]]></message>
<message level="Info"><![CDATA[Execution Runtime: Default]]></message>
<message level="Info"><![CDATA[..........]]></message>
<message level="Info"><![CDATA[Tests run: 10, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.9677115 seconds]]></message>
<message level="Info"><![CDATA[Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0]]></message>
<message level="Info"><![CDATA[***************** End Program Output *****************]]></message>
<message level="Info"><![CDATA[Execution Time: 2.8983 s]]></message>
<message level="Info"><![CDATA[Coverage Xml: C:\_documents\CI\_ncover_XTFL.UnitTests.Workflow.xml]]></message>
<duration>3278.1105000000002</duration>
</task>
If your NCover license allows, recommend upgrading to 3.4.18.
Based on the messages alone, it looks like profiling never begins on your NUnit process.
I can't see the exact command line syntax from the NAnt task, but NCover has to start NUnit in order to profile the unit test DLL.
If NCover is starting NUnit successfully, you should see a message after the "Program Output" that says, "Process 'nunit-agent' [PID 3116] has begun profiling" before the NUnit test results, and another message after the results that "Process 'nunit-agent' [PID 3116] has finished profiling".
I remember having a similar problem. Are you placing the related .pdb files besides the assembly files? That solved it for me.
That's a good tip re: the PDB files, but even without them, you should get Branch coverage, though you won't get any Symbols.

nant logs with data and time stamp

How to run NAnt scripts in command line and get the timings of each task on the log file?
using nant <record> task or
NAnt -buildfile:testscript.build testnanttarget
This produces console output but I can't see any timing information.
All I want each log message prefixed with datatime.
You can use the tstamp task to display the current date/time. Just include it everywhere where you want timing information. It will not prefix each line with a timestamp, but at least you can time some strategic points.
<tstamp />
Here is a sample of tstamp
<echo>
-----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
TASK : INITIALIZE
-----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
</echo>
<loadtasks assembly="nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" />
<!-- http://www.basilv.com/psd/blog/2007/how-to-add-logging-to-ant-builds -->
<tstamp>
<formatter property="timestamp" pattern="yyMMdd_HHmm"/>
</tstamp>
<property name="build.log.filename" value="build_${timestamp}.log"/>
<echo message="build.log.filename: ${build.log.filename}" />
<record name="${build.log.dir}/${build.log.filename}" action="Start" level="Verbose"/>
<echo message="Build logged to ${build.log.filename}"/>
<echo message="Build Start at: ${datetime::now()}" />
</target>