Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need batch Code for which execute every 5 minutes automatically

4,379 views
Skip to first unread message

sat

unread,
Jan 12, 2007, 5:46:19 AM1/12/07
to
Hi,

Need a batch code , which execute every 5 minutes automatically.

foxidrive

unread,
Jan 12, 2007, 7:24:07 AM1/12/07
to
On 12 Jan 2007 02:46:19 -0800, "sat" <kakas...@yahoo.co.in> wrote:

>Hi,
>
>Need a batch code , which execute every 5 minutes automatically.

Class assignment?

Tika

unread,
Jan 12, 2007, 10:36:36 AM1/12/07
to
sat wrote:
> Need a batch code , which execute every 5 minutes automatically.

:Loop
REM Put your batch file's code here.
REM ...

SLEEP 300
GOTO :Loop

Anything else is a bodge that can overtake itself.

Clay Calvert

unread,
Jan 12, 2007, 8:24:30 PM1/12/07
to
On 12 Jan 2007 02:46:19 -0800, "sat" <kakas...@yahoo.co.in> wrote:

>Need a batch code , which execute every 5 minutes automatically.

I'd use the Task Scheduler to run that task. In XP or 2003 the job
could be created with Schtasks.exe.

Another option is:

:loop
batch code here
ping -n 61 127.0.0.1>nul
goto:loop
Clay Calvert
CCal...@Zanguru.com
Replace "Z" with "L"

Tika

unread,
Jan 13, 2007, 11:58:54 AM1/13/07
to
Clay Calvert wrote:
> On 12 Jan 2007 02:46:19 -0800, "sat" <kakas...@yahoo.co.in> wrote:
>
>> Need a batch code , which execute every 5 minutes automatically.
>
> I'd use the Task Scheduler to run that task. In XP or 2003 the job
> could be created with Schtasks.exe.

If for whatever reason the batch takes longer than 5 minutes to run and
if it is not monitored properly it will use all system resources after
some time and render it unusable.

Clay Calvert

unread,
Jan 14, 2007, 2:06:04 AM1/14/07
to
On Sat, 13 Jan 2007 16:58:54 GMT, Tika <ti...@doesntexist.org> wrote:

>> I'd use the Task Scheduler to run that task. In XP or 2003 the job
>> could be created with Schtasks.exe.
>
>If for whatever reason the batch takes longer than 5 minutes to run and
>if it is not monitored properly it will use all system resources after
>some time and render it unusable.

If that is a concern then maybe set the "Until" section's "Duration"
for 4 minutes and then check the box: "If the task is still running,
stop it at this time."

If a recursive script truly hangs, then the task task no longer
repeats.

Tika

unread,
Jan 14, 2007, 8:37:34 AM1/14/07
to

This does not work reliably for batch files. Batch files consist of the
commands in the file itself with the process CMD.EXE. All external
commands are additional processes which are not monitored by your method.

NET USE...

If you kill the CMD.EXE for this batch file while NET hangs a process
NET.EXE will remain untouched in memory until the system is rebooted.
You will get a new NET.EXE process every 5 minutes, ie. 12 per hour (11
after the first hour). 10 hours add up to 120 hanging NET.EXE processes.

This is one of the easiest ways to make a production server crash for no
reason.

Todd Vargo

unread,
Jan 14, 2007, 10:55:00 AM1/14/07
to

Simple process detection for net.exe can be included in the batch to log and
abort if net.exe is still running (i.e. wait another 5 minutes). A log full
of abort entries can show duration that net.exe (or whatever) is hanging.

@echo off
pslist net.exe>nul
if errorlevel 1 goto :ready
echo ERROR: net.exe still running %date% %time% >>file.log
goto :eof

:ready
echo net.exe started @ %date% %time% >>file.log
net.exe ...


pslist formerly from http://www.sysinternals.com/

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Tika

unread,
Jan 14, 2007, 12:55:42 PM1/14/07
to
Todd Vargo wrote:
> Simple process detection for net.exe can be included in the batch to log and
> abort if net.exe is still running (i.e. wait another 5 minutes). A log full
> of abort entries can show duration that net.exe (or whatever) is hanging.
>
> @echo off
> pslist net.exe>nul
> if errorlevel 1 goto :ready
> echo ERROR: net.exe still running %date% %time% >>file.log
> goto :eof
>
> :ready
> echo net.exe started @ %date% %time% >>file.log
> net.exe ...

No doubt, there might be even more complicated ways to achieve what the
OP's asked. ;-)

It's still not usable on a production machine.

In order to make this safe you will have to check every process outside
the current CMD.EXE that might want user interaction or could crash/hang.

How do you want to find the NET.EXE that the batch file invoked? There
could be more of these processes on purpose, hence your log file's wrong
here.

It's simply not a good idea to look for common process names like
NET.EXE, CMD.EXE, etc.

Todd Vargo

unread,
Jan 14, 2007, 11:10:00 PM1/14/07
to

"Tika" <ti...@doesntexist.org> wrote in message
news:y8uqh.59840$Qa6....@newsfe6-gui.ntli.net...

Honestly! NET.EXE was just being used as an example (introduced by you). If
you really need a safety net from common process names, just make a copy of
net.exe (or whatever) to a unique name specified in the batch.

mat...@gmail.com

unread,
Jan 15, 2007, 2:55:38 AM1/15/07
to
Another way to monitor hang processes would be - write steps output
into log or flag files. Then check output first thing when batch
starts. If condition does not met - send warning and goto :EOF

Tika

unread,
Jan 15, 2007, 9:52:33 AM1/15/07
to
mat...@gmail.com wrote:
> Another way to monitor hang processes would be - write steps output
> into log or flag files. Then check output first thing when batch
> starts. If condition does not met - send warning and goto :EOF

If you reboot the machine after the flag file's created, you're in a
vicious circle.

Todd Vargo

unread,
Jan 15, 2007, 1:58:21 PM1/15/07
to
"Tika" <ti...@doesntexist.org> wrote in message
news:RyMqh.61311$Qa6....@newsfe6-gui.ntli.net...

No, you just don't know how to implement a flag file.

Clay Calvert

unread,
Jan 15, 2007, 2:24:00 PM1/15/07
to
On Sun, 14 Jan 2007 17:55:42 GMT, Tika <ti...@doesntexist.org> wrote:

>It's still not usable on a production machine.

I wouldn't completely discount running batch files as scheduled tasks.
I have a few scripts that have been running this way nearly every 15
minutes since 1999. Originally they were on NT4 machines, but now
those servers are running 2003. The tasks are set to kill running
processes after 12 minutes.

You do make a good point in that the scripts need to be checked
periodicallly to ensure they are closing properly. This is precisely
why I added the 'kill after 12 minutes' parameter.

Thanks,

naidu.a...@gmail.com

unread,
Apr 5, 2014, 4:56:25 AM4/5/14
to
superb ..its working

Stanley Daniel de Liver

unread,
Apr 7, 2014, 10:52:19 AM4/7/14
to
On Sat, 05 Apr 2014 08:56:25 -0000, <naidu.a...@gmail.com> wrote:

> superb ..its working
Good. Um which method did you use? You didn't quote anything.

--
It's a money /life balance.

frank.w...@gmail.com

unread,
Apr 7, 2014, 2:56:23 PM4/7/14
to
From "Stanley Daniel de Liver" :
>On Sat, 05 Apr 2014 08:56:25 -0000,
><naidu.a...@gmail.com> wrote:

>> superb ..its working
>Good. Um which method did you use? You didn't quote
>anything.

My guess is that it was a test message to see if a new
groogle Goups account was working. If it didn't work the
message would not have been there saying that it did. I
sent the same type of cryptic message once back in the
early days.

Frank


Frank
0 new messages