Solved

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

Posted on 2006-07-15
10
178 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 1

Author Comment

by:NemCert
ID: 17136515
Hello JohnBPrice,


I will try the tools and will c .

Thanks,
Nemcert
0
 
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

820 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