PHP: Recursively Delete Old Files
Useful for purging backup/temporary/cache files after a certain period of time.

Search for a command to run...
Useful for purging backup/temporary/cache files after a certain period of time.

No comments yet. Be the first to comment.
In this series, I will share code that is useful for solving problems. Talk code and dream code.
PHP Command Line Script
Most AI agents that support scheduled tasks have two sources of instruction when a cron job fires: The cron prompt — the task-specific instructions you wrote when scheduling the job The skill — a re

TL;DR Scarp draw result, host on GitHub, retrieve it like API at damacai.hongineer.com. Data Scraping I have previously shared a technique for scraping Da Ma Cai draw result. Now I finally have time t

This is a Bash script that check if the replica (slave) health status. If there is an issue, it will exist with non-zero status. This is useful when used with monitoring tools like [Monit](https://mmo

chmod is a command-line utility used to change the access permissions of file system objects such as files and directories. It allows you to control who can read, write, and execute those objects. Changing Permissions Using Octal Notation Example Usa...
chown changes the ownership of files and directories. This involves modifying the user and/or group associated with a file, determining who has access and permissions. Changing File Ownership to a Specific User Example Usage: chown user file.txt What...
I have a folder named "storage". There are log files and temporary cache files created within hierarchy of subfolders. I need to traverse through all subfolders and delete files older than 6 months (based on modified time).
$timeThreshold = strtotime("-6 months");
Files last modified before this timestamp will be deleted.
$iterator = new RecursiveDirectoryIterator($folder);
Using RecursiveDirectoryIterator for recursive folder traversal. listDeletableFiles function can be customize to filter files for deletion. For example, you may want to delete files with ".log" extension.