![]() |
php code snippet guru's, please ...
I have this to kill some older files, backups...
PHP Code:
Any idea how i can change this "kill all older than 7 days", into "kill all BUT the latest three" <- so, could be there's one in there that is weeks old, as long as no new ones appear I have had TM3 break and the kill older than x days backups. When we found out TM3 was broken, it had also killed all good backups already:( Anyone? We're going to cron this. |
can't you just change the > to <= and adjust the time?
|
btw i'm not a guru :D
|
No, that is my point;-)
|
You could place the file modified times, and file paths in an array. Sort by file modified times, remove the 3 most recent from the array, and recursively remove the remainder of the files.
|
Here you go. Hasn't been tested:
PHP Code:
|
One thing I noticed about all the code posted in this thread is that it will always delete every file, because $days isn't set anywhere, which means the conditional if(time() - filemtime($file)) > ($days *86400) is always gonna be true, because 0 times any number is always 0...
|
Quote:
Good looking out though..:thumbsup |
No idea. Good luck.
|
Quote:
//Remove the newest 3 files from the array Obviously we want to kill the oldest, not the newest, right? So how does that come about? |
Quote:
Does that make sense? |
Quote:
|
All times are GMT -7. The time now is 05:37 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123