Linux Script to remove files on specific directories with exclusions
Posted on 2016-10-21
I've been using a SFTP Centos 7.2 server using SSH service and I have to apply a script to remove files from several specific directories and sub-directories older than 30 days. In addition, I need to have the ability to exclude several sub-directories so that files won't get removed.
As an example, in my home folder I have 4 folders:
I need to remove all the files and directories older than 30 days from the SFTPWRITE on each of the 4 a01/a02/a03/a04 folders and to exclude several folders within SFTPWRITE folders as well so, let's say I need to exclude /home/a01/SFTPWRITE/exc01 folder.
Any advise how can I set this script up as a cron job?
Sorry guys if my question is basic but please bear with me as I'm a Linux beginner.