Solved

I need to create a small script "Batch" to run in Win2000 server

Posted on 2006-07-15
10
176 Views
Last Modified: 2010-04-17
Hi to all,

I need to create a small script "Batch" that should delete a file automatic, Thiese file area generated every day this the example of name of file :

error_log.1152921600    
access_log.1152964800
--------------------
error_log.1152921245
access_log.115292462

The number of the end of log always change its showing random, so ineed only to keeb for today and yesterday and before yesterday as backup example again today is 16-July-06 i need only to keeb files for 15 + 14 of july-06 and the other day should dele it auto ..

Note: in one day could the more that 4 files generate in the same name but different number.

Its clear ?

Thanks,
Nemcert
0
Comment
Question by:NemCert
  • 4
  • 3
10 Comments
 
LVL 1

Author Comment

by:NemCert
ID: 17116622
Its difficalt ?
0
 
LVL 2

Expert Comment

by:codoherty
ID: 17120964
If you don't mid spending a little, I use a scripting too called VIsualBuild from www.Kinook.com that will do just about anything, really well worth the money. Just a thought!
0
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 50 total points
ID: 17123054
Robocopy is a free tool in the windows resource toolkit which will do the trick for you

This will delete (move to recycle bin) any file in C:\test that is more than 3 days old
robocopy C:\Test C:\Recycled /MinAge:3 /MOV
0
 
LVL 1

Author Comment

by:NemCert
ID: 17136515
Hello JohnBPrice,


I will try the tools and will c .

Thanks,
Nemcert
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:NemCert
ID: 17136588
Hello JohnBPrice,

again how to add this script the scheduall ???

should i create new file .bat then add the line there and scheduall this every day or what ?

Thanks,
Nemcert
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17137812
Since it is only one command, you can put the robocopy command itself into the scheduled task (but you could put it in a bat if you like).  Remember to think about permissions, you might want to set an account/password for the scheduled task.
0
 
LVL 1

Author Comment

by:NemCert
ID: 17162421
About a permission noop coz am using the administrator user, I create a new file .bat and i was added the command line there but let me know the time in schedul should i slesct every day ? 0r run one times or what ?

I need the time and the date, What should i but in the scheduall ???

and there is one mistake in your command Recycler not Recycled  :)

robocopy f:\testlog C:\Recycler /MinAge:3 /MOV
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 17266308
Since you say the file is generated every day, I would schedule it every day.  The GUI for scheduled tasks in the control panel is simple enough to figure out.

>>and there is one mistake in your command Recycler not Recycled  :)
oops
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
base64 decode encode 12 119
Batch Login Script - Update default homepage 8 41
iframe detection of parent window scale 20 59
Copy dir and files with robocopy 2 30
A short article about a problem I had getting the GPS LocationListener working.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now