Discussion:
Writing to a Log file
(too old to reply)
RayRedSox
2009-10-21 17:50:32 UTC
Permalink
I have a batch file that runs a WMI command to do an IIS Reset on a
remote machine. When it's doing it, I want it to log the date/time that
the reset is done, but I'm having trouble getting it to work. Probably
an issue with my syntax. Here is my code:

wmic /node:"sup24app01" process call create "cmd /k date /t >
c:\maintenance\iis_reset_log.txt
wmic /node:"sup24app01" process call create "cmd /k iisreset

I'm not sure what I'm doing wrong, but the file doesn't get created
and, all I want is to append the date/time stamp within the contencts of
the file.

Any ideas would be much appreciated.

Thank you.
--
RayRedSox
------------------------------------------------------------------------
RayRedSox's Profile: http://forums.techarena.in/members/146555.htm
View this thread: http://forums.techarena.in/server-scripting/1261234.htm

http://forums.techarena.in
Mike 'Spike' Lovell
2009-10-21 18:33:31 UTC
Permalink
Post by RayRedSox
I have a batch file that runs a WMI command to do an IIS Reset on a
remote machine. When it's doing it, I want it to log the date/time that
the reset is done, but I'm having trouble getting it to work. Probably
wmic /node:"sup24app01" process call create "cmd /k date /t >
c:\maintenance\iis_reset_log.txt
wmic /node:"sup24app01" process call create "cmd /k iisreset
I'm not sure what I'm doing wrong, but the file doesn't get created
and, all I want is to append the date/time stamp within the contencts of
the file.
date will wait for user input, you can do this:

echo %date% %time% >> <filename>

(use two ">" which means append, otherwise you'll only see the last time it
happened)

~ Mike
Al Dunbar
2009-10-21 23:39:52 UTC
Permalink
Post by Mike 'Spike' Lovell
Post by RayRedSox
I have a batch file that runs a WMI command to do an IIS Reset on a
remote machine. When it's doing it, I want it to log the date/time that
the reset is done, but I'm having trouble getting it to work. Probably
wmic /node:"sup24app01" process call create "cmd /k date /t >
c:\maintenance\iis_reset_log.txt
wmic /node:"sup24app01" process call create "cmd /k iisreset
I'm not sure what I'm doing wrong, but the file doesn't get created
and, all I want is to append the date/time stamp within the contencts of
the file.
date will wait for user input,
not when used with the "/T" switch.
Post by Mike 'Spike' Lovell
echo %date% %time% >> <filename>
Yes, he can do that - assuming he wants to log the date and time locally,
and wants the local time to be the time that is used. I thought he was
running the command remotely in order to have the remote time logged.

/Al
Mike 'Spike' Lovell
2009-10-22 03:55:31 UTC
Permalink
Post by Al Dunbar
not when used with the "/T" switch.
Which he wasn't doing ;o)
Post by Al Dunbar
Yes, he can do that - assuming he wants to log the date and time locally,
and wants the local time to be the time that is used. I thought he was
running the command remotely in order to have the remote time logged.
I don't understand what you're saying, "date" and the above echo - Both the
local time where they are run. He never mentioned any other requirement.

~ Mike
Al Dunbar
2009-10-22 23:56:08 UTC
Permalink
Post by Mike 'Spike' Lovell
Post by Al Dunbar
not when used with the "/T" switch.
Which he wasn't doing ;o)
Is that a "/t" following the word "date" in the first line?

wmic /node:"sup24app01" process call create "cmd /k date /t >
c:\maintenance\iis_reset_log.txt
wmic /node:"sup24app01" process call create "cmd /k iisreset
Post by Mike 'Spike' Lovell
Post by Al Dunbar
Yes, he can do that - assuming he wants to log the date and time locally,
and wants the local time to be the time that is used. I thought he was
running the command remotely in order to have the remote time logged.
I don't understand what you're saying, "date" and the above echo - Both
the local time where they are run. He never mentioned any other
requirement.
He was perhaps not explicit, but since some of the remote machines he wants
to do an IIS Reset on might be located in another timezone, it is a
possibility I wouldn't discount.

/Al
Mike 'Spike' Lovell
2009-10-23 14:43:41 UTC
Permalink
Post by Al Dunbar
He was perhaps not explicit, but since some of the remote machines he
wants to do an IIS Reset on might be located in another timezone, it is a
possibility I wouldn't discount.
It's all a bit academic now! Looks like he's decided it was resolved
without posting so.

~ Mike

Loading...