Scheduled Tasks: "Repeat Every..." question

  • Thread starter Thread starter Eugene F.
  • Start date Start date
E

Eugene F.

Hi

What exactly should happen when a job scheduled to run every hour
sometime takes more than hour to complete?

If it is documented, please pint me in the right direction.

TIA, Eugene
 
Hi

What exactly should happen when a job scheduled to run every hour
sometime takes more than hour to complete?

If it is documented, please pint me in the right direction.

TIA, Eugene

It all depends on what the task was scheduled to do. If the task was
running simple commands that can be run concurrently the second task
would start on the hour and run concurrently with the first one.

On the other hand if the task was running commands requiring exclusive
access on objects the second task set to start on the hour would fail
silently.

For example:

The ping command is a simple command which can run concurrently with
another ping command, you can run multiple instances of the command at
the same time. You could ping the localhost for 5 minutes (PING -n 300
127.0.0.1>nul) and have the task run every minute for five minutes and
all five tasks would start and complete, the tasks would run concurrently.

On the other hand a command like chkdsk which places an exclusive lock
on a volume cannot run concurrently with another chkdsk on the same
volume. If you wanted to run chkdsk /r on a data disk the first task
would place an exclusive lock on the disk and the second task would not
be able to gain access to the disk so it would fail silently. The same
would happen with other commands which lock objects, for example a task
might get an exclusive handle on a file and lock it and the second task
would be unable to gain access to the file so it would fail. You can
take a look at the Scheduled Task log file to see if the tasks started
and completed without errors.

John
 
John,

Thank you very much for the reply.

The task is a 16-bit DOS application that I wrote. Is embedding the
locking into the application itself (or its batch file) the only way
to ensure that only one instance runs at a time?

Using your chkdsk example, what happens after the task's silent
failure? Will the next one start (or attempt to start) right on
schedule?

Please clarify.

TIA, Eugene
================================================================
 
John,

Thank you very much for the reply.

The task is a 16-bit DOS application that I wrote. Is embedding the
locking into the application itself (or its batch file) the only way
to ensure that only one instance runs at a time?

You could put "if" statements in your routine and do actions
accordingly, for example:

Have the routine create a marker file and delete it when it's done and
have the routine check for the marker file when it starts:

if exist c:\marker.txt goto :eof
echo >c:\marker.txt
run some commands here...
del c:\marker.txt

Or you could use the Tasklist command to check for the presence of a
process and take actions accordingly.

Using your chkdsk example, what happens after the task's silent
failure? Will the next one start (or attempt to start) right on
schedule?

Yes, it will try to start again in accordance with the task's schedule,
if at any scheduled interval the disk is available chkdsk will run. If
the task is set to run every 10 minutes for one hour the task will try
to start every 10 minutes, if the disk is locked the task will silently
fail but it will try again in another ten minutes, if the disk is then
free chkdsk will run. It will keep on trying every ten minutes for one
hour.

John
 
John,

Thank you for the clarification.

Eugene

====================================================
 
Back
Top