Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto delete all files after x-time

How do you auto delete all files under a sub directory after x-time (let say after 24 hours) - without using a cronjob command from server or pl. How can you do this just using PHP code or by just visiting the page without clicking something and the command auto runs.

like image 594
jones Avatar asked Dec 17 '09 12:12

jones


People also ask

How do I automatically delete files after a certain time?

You can free up space and keep things organized by only deleting files that are older than a certain number of days in any folder — here's how to do it. To delete files older than 30 days on Windows 10, use the “ForFiles” command. The command is: ForFiles /p “C:\path\to\folder” /s /d -30 /c “cmd /c del /q @file”.

Can files be deleted automatically?

Storage Sense in Windows 10 is a new feature. When you enable it, Windows will automatically delete unused files when the computer is low on disk space. For instance, it can automatically delete files older than 30 or 60 days from the Recycle Bin or delete temporary files to free up some space.


1 Answers

I use shell AT command, it's like a cronjob though

php:

exec("echo rm /somedir/somefile.ext|at now +24 hours");
like image 64
pwr Avatar answered Oct 13 '22 00:10

pwr