I want to run a cron job that delete all files in a directory when it exceeds a number. For example when it become 1000 files, then delete all files in that directory. The goal is clearing cache directory.
Let's do this step by step. If your cache folder path is ./Cache, you can count the number of file under it this way:
Based on the above description, we can write a simple shell:
* [Linux 命令] find : 尋找特定字串的檔案或目錄
* Linux find 命令使用詳解