I am generating temp files.. I know that i can use a cron job, to clean up. I was wondering.. is there some place on a linux box where any user can naturally put temp files? does the tmp dir work like that? so i can gerenate temp junk endlessly without worry of clean up ?
Also I don't want to be a buttmunch asking this stuff in the wrong place.. is there a more appropriate (although i already know not better.. ) place where i can ask unix/linux questions that could be suggested? I'm having a hard time finding a good place for this. Thank you ahead for any help. I hope I don't annoy anyone with this.
File::Temp is a useful way to create tempfiles, but you'll still have to figure out how to get them cleaned up.
Also, it's best if you can clean them up yourself, and only leave them lying around in the rare case that your program crashes. Things like END blocks are useful places for this sort of cleanup.
Sick Unix Trick #347 ... ghost files.
# Open the file, creating it open $fh, '+>', 'foo.txt'; # Immediately unlink the file ... it will remain # until you close the filehandle, then disappear unlink 'foo.txt'; # Put something in it to test print $fh "Foo\n"; # Rewind to the start of the temp file seek $fh, 0, 0; # Read it back in and see what you have $in = <$fh>; print "Read: $in\n"; # You don't even *have* to remember to close it, # but it is a good habit ... close $fh;
By unix rules, the system normally should not remove anything from /tmp while running. In /tmp any program is supposed to be able to create files, write to them, and assume that files placed there will remain until removed by the owner. A program can not assume that the contents of /tmp will survive a reboot. That makes startup scripts the place for the system to do /tmp cleanup.
Some admins put in place some other policy they dream up, but the unix police will someday get 'em.
Putting /tmp on its own spindle, or at least a large partition, and mounting with the sticky bit set fixes most problems that non-unix policies are meant to solve. Going all BOFH on programs which don't clean up after themselves takes care of the rest.
Of course, users may clean up their own messes any time they like.
After Compline,
Zaxo
Of course there are plenty of Unix/Linux monks here...In which case, we prefer you to use the Chatterbox to ask quick questions.
perlmonks.org content © perlmonks.org and bart, chrism01, idsfa, leocharre, perrin, sgifford, Zaxo
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03