LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2008, 12:19 PM   #1
Flugelhornchris
LQ Newbie
 
Registered: Sep 2006
Location: Orlando, FL, US
Distribution: Puppy 2.14, Ubuntu 6.10
Posts: 15

Rep: Reputation: 0
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.
 
Old 01-25-2008, 01:42 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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
--- rod.

Last edited by theNbomr; 02-03-2008 at 11:45 AM.
 
Old 01-26-2008, 04:07 AM   #3
Big_Vern
LQ Newbie
 
Registered: Jan 2008
Posts: 9

Rep: Reputation: 1
Quote:
Originally Posted by Flugelhornchris View Post
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.
Hows about calling somethin like this when the profile is loaded?
Code:
find /the/directory/* -mtime +1 -exec /bin/rm -rf {} \; 2>/dev/null 1>&2
 
Old 01-26-2008, 04:54 AM   #4
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,454
Blog Entries: 7

Rep: Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559
Quote:
Originally Posted by Flugelhornchris View Post
I need it to be in either c or c++.
Homework question?
 
Old 01-26-2008, 11:50 AM   #5
Flugelhornchris
LQ Newbie
 
Registered: Sep 2006
Location: Orlando, FL, US
Distribution: Puppy 2.14, Ubuntu 6.10
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 02-02-2008, 04:12 PM   #6
Flugelhornchris
LQ Newbie
 
Registered: Sep 2006
Location: Orlando, FL, US
Distribution: Puppy 2.14, Ubuntu 6.10
Posts: 15

Original Poster
Rep: Reputation: 0
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?
 
Old 02-03-2008, 11:48 AM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 02-03-2008, 01:51 PM   #8
v00d00101
Member
 
Registered: Jun 2003
Location: UK
Distribution: Devuan Beowulf
Posts: 514
Blog Entries: 1

Rep: Reputation: 37
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
md x:\some\folder
How to make it run on login.

http://www.windowsnetworking.com/art.../wxpplogs.html
 
Old 02-04-2008, 12:52 PM   #9
Flugelhornchris
LQ Newbie
 
Registered: Sep 2006
Location: Orlando, FL, US
Distribution: Puppy 2.14, Ubuntu 6.10
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete temp files. caa1980 Ubuntu 6 03-29-2010 07:47 AM
How to create/delete temp/backup files through a shell script ? Sid2007 Programming 4 10-17-2007 01:55 PM
Do have to clean temp.files, ....? schneemann SUSE / openSUSE 3 01-16-2006 11:05 PM
How To Delete temp Internet Files? agee220 Linux - Newbie 3 08-25-2004 02:36 PM
temp files Daggelicious Linux - Newbie 2 08-21-2003 10:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration