1.How best we can define a task using task scheduler in windows server.
Before getting into actual topic we must know the task types.Generally we can see two types of tasks in scheduler, one is Basic task and another one is Task.Basic task is one which we can create using scheduler wizard with minimal options where as Task is the one which have lot of options to be customized and will created in desired manner.
Also we can see the difference between task scheduler console based on OS versions. Here we take Windows 2003 and Windows 2008 R2 as an examples.
To open a console, go to
Control panel>Scheduled Tasks —in windows 2003
Control Panel\All Control Panel Items\Administrative Tools\Task Scheduler –in windows 2008 R2
Windows 2003 Console view
Create Basic task:- Follow the steps based on the schedule task wizard. Useful snap-shot.
Control panel>Scheduled Tasks>File>New>Scheduled Task
Properties window will be like below and have less options, tasks to be run from command/script.Time to run a task followed by the settings. Security settings to run a task in general (local/domain) user/admin or local system authentication.
When we see windows 2008 R2 console,we can have lot of options to define a schedule task and window will like below.
I personally observed many times, defined task in task scheduler not giving the results as user/administrator expected.
Possible errors are
Improper security options. In general we have two options
Run only when user is logged on —Tasks runs only when user session is active.
Run whether user is logged on or not—Tasks runs irrespective of user session is active/in-active. But when choose this option we have to enter user credentials info, server caching this info and will be used when its needed. But this is not a reliable option why because according to IT security policy user passwords will change for every 45 days.
So, schedule tasks will be used for long run may fail to run. To avoid failures we have to use local system account for authentication purpose.Also many of script based/program based tasks can be configured using local system account.
When you are working with windows 2008/2008 R2 task scheduler, tasks can be configured based on the version. If we miss this there will be a chance failures. So we must be keen in setting up proper configuration option.
2. Sample illustration to reboot a server on schedule basis.
So we have to create a task with the help task scheduler and reboot the server once in a week.
- Creating a task to restart server on every Sunday at 23:35
- Enabling Triggers: Configure the task how often or when it can be planned to run.
- Actions: Create batch file using command “shutdown /r /f“and save it in root of C partition.Then configure script path settings and follow the wizard.
- Conditions:Follow the default settings if you don’t to do any customization.
- Settings:Configure settings based on your task requirement.
- History: This help us monitoring the schedule task how is running and moreover it will help us in troubleshooting when we have issue with particular task
The above illustration is applicable to Windows Server 2008 & 2008 R2
3.Schedule task completed with error code 0X1:
Generally some task which are defined in task scheduler completed with error.It may be because of improper settings of task configuration.
Open a Task Scheduler console from Control Panel\All Control Panel Items\Administrative Tools\
Choose Create new task/create basic task and follow task wizard steps.
General settings and choose the options as per the below snap-shot.
Trigger>Choose the specific time/date when the task should be run.
Actions>This tab is heart of the task and use particular program or script to run. Better use C:\ or C:\tasks folders for script path instead of desktop and other places.
Conditions and Settings>These tabs are the options we can use to define a task more precise manner.
History>This tab gives us more info that when the task has been started, how it is running details like process, services info and when it is completed successfully.Also gives us info that the task might be completed with warnings/errors.
Reference links:Technet link: http://technet.microsoft.com/en-us/library/cc766428.aspx