Michael Ryden
Michael Ryden

Reputation: 33

How to have cron delete file sizes over certain size

Can someone please tell me what command line to input into cron to delete all files in a certain directory over a certain size. Thank you

(I'm on an apache server... and I'm using the cpanel cron program)

Upvotes: 2

Views: 1428

Answers (1)

Anshul Goyal
Anshul Goyal

Reputation: 77053

Try using

find path/to/directory -type f -size +150k

for specifying file size in kb. In case you need limit in MB some other day, use 150M instead.

The current command will delete all files within that directory and its subdirectory, so you may want to use the maxdepth option for deleting files within a directory and not in its subdirectories

find path/to/directory -maxdepth 1 -type f -size +150k

Upvotes: 3

Related Questions