?
Solved

rm ubuntu schedule

Posted on 2009-07-08
4
Medium Priority
?
270 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

771 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