Solved

rm ubuntu schedule

Posted on 2009-07-08
4
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Users are often faced with high disk consumption without really knowing where the largest amount of data resides. Disk Usage Analyzer (aka Baobab) is is a graphical, menu-driven application to analyse disk usage in any Gnome environment and can e…
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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