How to Schedule a Job in Windows Similar to Cron job in Linux ?

Going forward codeinspections will also be covering topics which we be useful for techies in their day to day jobs and this is first post in this series. Today we will learn how to schedule a job in windows. Linux guys will be aware of scheduling the jobs using cron there is similar way to schedule job in windows as well. Scheduling job is very important task especially for testers, testers need to schedule their auotmated test execution.
Windows jobs can be scheduled either from command prompt or from the UI. Below we mention ways to do it:
Using UI:
  1. Click Start> All Programs > Accessories > System Tasks > Scheduled tasks
  2. Right Click and create new task and give some name
  3. Right Click and click on properties
  4. Add any command say "cmd /c dir > c:\test.out"
  5. We can set the schedule from the schedule tab
  6. We can set the user under which to run this task
Using Command Prompt:
  1. Go to command prompt (Click on Start>Run and enter cmd)
  2. Use the AT command to schedule the job
  3. By default all command line tasks will run under System by default
  4. AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]] (to delete the task) AT [\\computername] time [/INTERACTIVE][ /EVERY:date[,...] | /NEXT:date[,...]] "command"
    \\computername Specifies a remote computer. Commands are scheduled on the
    local computer if this parameter is omitted.
    id Is an identification number assigned to a scheduled
    /delete Cancels a scheduled command. If id is omitted, all the
    scheduled commands on the computer are canceled.
    /yes Used with cancel all jobs command when no further
    confirmation is desired.
    time Specifies the time when command is to run.
    /interactive Allows the job to interact with the desktop of the user
    who is logged on at the time the job runs.
    /every:date[,...] Runs the command on each specified day(s) of the week or
    month. If date is omitted, the current day of the month
    is assumed.
Did this article help ? Post your comments.

No comments:

Post a Comment