It is not recommended to immediately purge logfiles as they may be needed later for debugging, statistics or tracing an intrusion. While log shipping offsite may be overkill in a single VPS scenario, there are better approaches than simply deleting those. I suggest you look into logrotate or cronolog (Probably available as package on CentOS). With these packages you can set up rules how to process logfiles on a (usually) daily basis, like: Keep a week worth of logs, but compress all of them except today's.
What I would suggest here is creating a cron job that runs every night. Change to ‘+14’ to delete files older. 5 responses to Delete files that are x days. I need to remove files older than 3 days with a cron job in 3. Sign up or log in. See for instance Why did find with -delete erase the files in my /save.
First, this command will find and delete all files older than 7 days in any subdirectory in /home whose name starts with securityuser: find '/home/securityuser*' -mtime +6 -type f -delete You need -mtime +6 and not +7 because -mtime counts 24h periods. As explained in the -atime section of man find ( -mtime works in the same way): -atime n File was last accessed n*24 hours ago.
When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago. So, to find a file that was modified 7 or more days ago, you need to find files that were modified more than 6 days ago, hence -mtime +6. The next step is to have this command run once a day. Since each securityuserN is a different user (you might want to rethink that setup, it makes everything more complicated), this must be run as root.
Canon Lbp 2900 Printer Driver For Windows 8 64 Bit. So, edit /etc/crontab: sudo nano /etc/crontab And add this line: @daily root find '/home/securityuser*' -mtime +6 -type f -delete That will run the find command once a day and delete the files.