Find the answer to your Linux question:
Results 1 to 4 of 4
I have a script running as a cronjob It outputs logs upon each run to /var/log/mylog.log Is there anyway I can delete this or compress it when it gets too ...
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    59

    How to automatically delete log files?

    I have a script running as a cronjob

    It outputs logs upon each run to /var/log/mylog.log

    Is there anyway I can delete this or compress it when it gets too large?

    A cheap and dirty way is to setup another cronjob to delete the log every X interval.... although I'm not sure if that's the proper way

    Thanks

  2. #2
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    You must always face the curtain with a bow.

  3. #3
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,095
    logrotate should compress and remove log files automatically:

    logrotate

    Code:
    man logrotate


    oops, looks like Irithori was quicker than me on the ENTER key.
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

  4. #4
    Just Joined!
    Join Date
    Jan 2011
    Posts
    59
    Thanks guys! This looks like what I was looking for

    Is there a way to view all the logs that are currently maintained by logrotate? For example, the command "crontab -e" lets you view all the cronjobs for a particular user. Is there an equivalent for logrotate?

    Also... Am I correct in assuming that all logs under /var/log/ are automatically maintained by logrotate?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...