After a while this content becomes stale and can be deleted.
The holding folder is
/home/user/holding/
and the folders created are
/home/user/holding/20151221
/home/user/holding/20151222
/home/user/holding/20151223
I want to delete directories older than x days
The following commands will delete files only and not the directories.
/usr/bin/find /home/user/holding/ -type f -mtime +5 | /usr/bin/xargs rmTo delete directories and files included, modify the above and change rm to rm -rf
/usr/bin/find /home/user/holding/ -type f -mtime +5 -exec rm -rf {} \;
/usr/bin/find /home/user/holding/* -mtime +5 | /usr/bin/xargs rm -rfNote the asterisk and the removal of "-type f"
Testing
Checking with -mmin +1 i.e. files/directories modified over 1 min ago. Always test what you are going to delete before proceeding.
/usr/bin/find /home/user/holding/* -mmin +1
/home/user/holding/20151221
/home/user/holding/20151222
/home/user/holding/20151223
/usr/bin/find /home/user/holding/ -mmin +1
/home/user/holding/Therefore to delete the folders/directories in /home/user/holding/ and not /home/user/holding/ itself use /usr/bin/find /home/user/holding/*
/home/user/holding/20151221
/home/user/holding/20151222
/home/user/holding/20151223
Complete
Using with cron to delete folders older than x days, in this case 5, use the following.
0 6 * * * /usr/bin/find /home/user/holding/* -mtime +5 | /usr/bin/xargs rm -rf > /dev/null
Note be very careful with rm -rf. It can wipe out your entire system if incorrectly used. Always test what you want to delete before attempting to do so