Login Script - log files overwritten

J

John

I have a script (cmd file) is being called from the login
script. If a condition is met the computer name is
written to a log file housed on a share. Users have
rights to write to the file but not delete. The problem
is randomly (once or twice a week) the log file is being
overwritten. I have seen happen with different script(s)
and different log files.

An example of the syntax in the script(s) is below:

echo %COMPUTERNAME% >> \\servername\share\logfile

ideas? Two users writing to the file at the same time ?

thanks
 
P

Pegasus \(MVP\)

John said:
I have a script (cmd file) is being called from the login
script. If a condition is met the computer name is
written to a log file housed on a share. Users have
rights to write to the file but not delete. The problem
is randomly (once or twice a week) the log file is being
overwritten. I have seen happen with different script(s)
and different log files.

An example of the syntax in the script(s) is below:

echo %COMPUTERNAME% >> \\servername\share\logfile

ideas? Two users writing to the file at the same time ?

thanks

You are correct: If two users run the script at the same time
then you get a file sharing violation error. To avoid this trap,
code like this:

echo %ComputerName% >> \\ServerName\share\%ComputerName%

You now schedule a task that runs once every night on the server:

@echo off
if not exist \\ServerName\share\collect md \\ServerName\share\collect
for %%a in (\\ServerName\share\*.*) do
type %%a >> \\ServerName\share\collect\collect.txt
del /q \\ServerName\share\collect\*.*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top