Say there’s are alot files being created in a folder and it causes full disk space problem, here’s one of the example to remove the files that is older that 2 days:
find /home/user/yourpath/ -mtime +2 -type f -exec rm -rf {} \;
Or if you want to maintain that as a scheduled cron job, here’s the example of full code that you can use:
#!/bin/sh
###############################################
## Shell script to run housekeep glassfish ##
## delete server.log older than x days ago ##
## Date : 24-May-11 ##
###############################################
##declaring variables
echo “HOUSEKEEP started…”
A_LOG_PATH=~/opt/yourpath/
PAST=2
find $A_LOG_PATH -mtime +$PAST -type f -exec rm -rf {} \;
ehco “HOUSEKEEP ends…”