Clearing Logs Regularly with Cron
Your Virtual Server's logs are appended to every time someone visits your
site. Over time these logs can grow to be very large and can consume all
your available disk space if not managed correctly.
You can easily define a simple cron
table entry in your cronjobs file to nuke your log files. The
instructions included below guide you through this process step by step.
That's all there is to it! You can list your registered cron table entries
- Create a cronjobs file
You can do this on your local computer in a text editor like TextPad
or you can create the file directly on your Virtual Server using your
favorite UNIX text editor (pico, vi, etc). Your file should contain
the following entries:
0 1 1 1-12/3 * /usr/local/bin/vnukelog
This will run the vnukelog
command (which clears all of your log files) at 1 AM on the first day
of the first month of every quarter, or January, April, July, and October
(1-12/3). The log file contents will be emailed to the address set in
the MAILTO field. Obviously,
you will need to substitute a valid e-mail address in the place of "USER@YOUR-DOMAIN.NAME".
If you have created your cronjobs file on your local computer, FTP the
file up to your Virtual Server and store it in your home directory under
the name "cronjobs" (you can actually use any name you would like).
See the Crontab Page
for more information making a cronjobs file.
- Register your cronjobs file with the system
After you have created your cronjobs file (and have uploaded it to your
Virtual Server if applicable), you need to Telnet
or SSH to your server and register the file with the cron system
daemon. To do this, simply type:
Or if you created a file name other than "cronjobs",
substitute the name you used for the place of "cronjobs"
or remove all of your registered cron table entries by typing: