Delete old uploads

Bash skripty
User avatar
Ashus
Administrátor
Posts: 417
Joined: 07. 07. 2007 10:51
Location: Ostrava - Polanka nad Odrou
Contact:

Delete old uploads

Postby Ashus » 08. 02. 2013 20:15

To automatically delete older uploads, use this and add the script to your cron. +7 means files need to be older than 7 days, files beginning with a dot and a folder "up" is ignored.

Code: Select all

#!/bin/sh

IFS=$'\n'
for s in $(find /var/www/files/upload/ -type f -mtime +7 -exec echo {} \; | egrep -v "/var/www/files/upload/(\.|up/)")
	do
	rm "$s"
	done
Image
Coffee phreak!

Who is online

Users browsing this forum: No registered users and 1 guest

cron