delete yesterday's temp files
Hi, I have a very limited knowledge of programming, but I need to write a program that will go into a particular folder and delete anything in it that was not created the same day the program is run. I need it to be in either c or c++. I'll put this to run everytime someone logs on to the computer so I need it to check the day, not time specifically. Thanks.
|
Since you aren't a programmer (and I don't know why you'd want it in C/C++), how about a cron job that runs every midnight, and deletes everything in the specified directory?
Code:
0 0 * * * rm -rf /the/directory/you/want/to/clean/out |
Quote:
Code:
find /the/directory/* -mtime +1 -exec /bin/rm -rf {} \; 2>/dev/null 1>&2 |
Quote:
|
No, its not a homework question, I took C++ class 6 years ago and don't remember anything except very basic and general information. This is gonna run on a windows machine, they're for the biology lab laptops which students use. We don't leave them running 24/7 and they're not connected to the server so that we can tell them to turn on and run anything at midnight. So I just need a quick program that does the deleting everytime the student turns and logs on the laptop. Trust me if it ran Linux I wouldn't be asking for help, but the school makes the decision on what to run on them not me :(. Thanks a bunch guys.
|
ok it doesn't matter if its c or c++, but I need something that isn't done in a scripting language like perl. I already wrote the program in Perl and I was told it would be best if I didn't write it in as a script. Can anyone help?
|
No one I know would even think of doing such a task in C/C++. Wrong tool for the job. It makes a trivial job into a significant project. There is a reason scripting langugaes like perl were invented, and this is one of them. What reason(s) were you given that C/C++ would be best?
--- rod. |
Since you dont specify whether windows 9x or NT family, here goes the commands i'd use to torch a folders contents on XP.
Code:
rmdir /q x:\some\folder http://www.windowsnetworking.com/art.../wxpplogs.html |
Thanks for the info on making it run on login and how to get rid of the folder. now I need to know how to compare the date stamp on files to todays date (time in hours or seconds not necessary).
The reason for C/C++ is a stupid one: beaurocracy. Everything that goes on the college computers has to be approved by the college, and they don't want to put in a scripting compiler (is it called a compiler?) in the laptops. They already have MS Visual C++ or something MS-ey on them and would rather use that instead. I'm trying my best here come up with the code myself, and I think C++ is giving me more to work with, but I still need help. Thanks for the patience and time, I really appreciate it. |
All times are GMT -5. The time now is 08:45 AM. |