Solved

rm ubuntu schedule

Posted on 2009-07-08
4
261 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

726 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