Solved

rm ubuntu schedule

Posted on 2009-07-08
4
252 Views
Last Modified: 2013-11-15
hi,

I have lots of log files in /etc/log how can we schedule/cron to have it remove files older than X numer of days?

The file is owned by root so I have to sudo su - I'm not sure how to do this..

Cheers!

0
Comment
Question by:mikesteven
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:medvedd
ID: 24806437
There is a special program for this, called logrotate. Please read 'man logrotate' for details.
0
 

Author Comment

by:mikesteven
ID: 24806512
can we create a script and delete files older than X number of days?
0
 

Author Comment

by:mikesteven
ID: 24806752
found it , find "$DIR" -type f -mtime +$TIMEVAR -ls
0
 
LVL 16

Accepted Solution

by:
medvedd earned 500 total points
ID: 24806767
For deleting files you can use:

sudo find /etc/log -mtime +X -exec rm {} \;

Put number of days instead of X
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question