------------------------------------------------ On Wed, 27 Aug 2003 10:28:46 -0400, [EMAIL PROTECTED] wrote:
> Correct me if i'm wrong, you say use cron and a shell script (let's say bash) > instead of perl? > well, if there are any other ways of doing it instead of using cron, id love to head > about it. > Is there a way to know when a user leaves the site? if so can i make it run the > clearing script when a user leaves? (i know this isn't close, but IE like the way > bash runs ~/.bash_logout when user logs out?) > Sorry I wasn't terribly clear, I wasn't suggesting a bash shell script, more a single command. --Untested-- find . -amin -1 -exec rm {}; For instance works under RH 9.0. Some versions of 'find' may not have the 'amin' switch, for instance Solaris 8's 'find' does not. Though in that case you could still build a command using some of the switches such as 'newer' that might work. As to being able to track when a user has left the site, it isn't really possible hence stateless connection, but since I am somewhat of a purist just because someone hasn't accessed the site for 5 minutes doesn't mean they aren't still there. So to me temporary information should be stored with the user, then their session ends when they close the browser (weeks later), etc. and only permanant information is stored on the server, then there is no cleanup. As far as scheduling a task, cron works best, but there are other options such as having a script constantly running that 'sleep's, etc. If you are doing this frequently then the amount of time to fire up the interpreter does come into play, the longer the interval than the less frequent the compilation/interpreter has to run the less likely that it matters. However a constantly running script has its problems too..... My questions would be, 1) do you need to store the state on the server side? 2) how many files are you talking about? 3) how long "can" they last for? 4) how long must they not be stale for? 5) what happens when a file is not cleaned up on time? (aka how important is it that they be whacked?) http://danconia.org > [EMAIL PROTECTED] wrote: > > > > >------------------------------------------------ > >On Wed, 27 Aug 2003 16:18:00 +0200, Shahar Evron <[EMAIL PROTECTED]> wrote: > > > >> hi... > >> I'm working on a CGI program that creates some user-specific file on the > >> server when accessed. is there a good way to make sure theese files are > >> cleared when they're no longer needed - IE if a file in a specific > >> directory was not accessed for 5 minutes, delete it. > >> Right now i'm thinking a croned script - but it would have to be run > >> quite oftenly - won't that have a bad effect on my system? > >> I'd love to hear some ideas. > > > >This is highly dependent on the frequency with which you run the script, the number > >of files, possibly the size of the files, etc. cron in itself is going to be > >running anyways (most likely) having it fire up a single process to remove some > >files isn't terribly slow, until you are talking about large amounts of files or > >you run it very often like every couple of seconds. So the question becomes how > >long "may" a file stay out there, because this determines how frequently you must > >run the script, in other words, if a file has not been accessed in five minutes but > >must be deleted before it is stale for 6 minutes then you have to run the script > >every 59 seconds. etc. > > > >If you must take this approach and are on a unix system, I would avoid a Perl > >script and install a recent version of 'find' and use 'rm' instead. That should > >speed up the file location and removal without the overhead of the perl interpreter > >being fired up. > > > >http://danconia.org > > > >http://danconia.org > > > >-- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > __________________________________________________________________ > McAfee VirusScan Online from the Netscape Network. > Comprehensive protection for your entire computer. Get your free trial today! > http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397 > > Get AOL Instant Messenger 5.1 free of charge. Download Now! > http://aim.aol.com/aimnew/Aim/register.adp?promo=380455 > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]