Solved

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

Posted on 2006-07-15
10
173 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
Comment Utility
Its difficalt ?
0
 
LVL 2

Expert Comment

by:codoherty
Comment Utility
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
Comment Utility
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
Comment Utility
Hello JohnBPrice,


I will try the tools and will c .

Thanks,
Nemcert
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:NemCert
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
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…

772 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

11 Experts available now in Live!

Get 1:1 Help Now