Web Hosting Talk







View Full Version : Cron and Scripts EASY question


Garrett
09-23-2002, 05:43 PM
Seems easy, but then again I am ***way*** too lame in my linux know-how. But I'm getting there.

Anyways, for some reason this server that was setup doesn't have a logrotate script built into it. The logrotate command is there, but for the life of me I can't figure out how to get it to "go" on the file that is growing by 400 megs per day...

So, I wanted to setup a cron job to rotate them every day, and dump them after 7 days. Here's what I would like it to do:

rm /usr/local/apache/domlogs/logname_7
mv /usr/local/apache/domlogs/logname_6 /usr/local/apache/domlogs/logname_7
mv /usr/local/apache/domlogs/logname_5 /usr/local/apache/domlogs/logname_6
mv /usr/local/apache/domlogs/logname_4 /usr/local/apache/domlogs/logname_5
mv /usr/local/apache/domlogs/logname_3 /usr/local/apache/domlogs/logname_4
mv /usr/local/apache/domlogs/logname_2 /usr/local/apache/domlogs/logname_3
mv /usr/local/apache/domlogs/logname_1 /usr/local/apache/domlogs/logname_2
mv /usr/local/apache/domlogs/logname /usr/local/apache/domlogs/logname_1
/etc/rc.d/init.d/httpd graceful


My question is this:

1) should I setup logrotate rather than cron-jobbing it? If so, can someone help me set it up besides recommending logrotate --help (which I do not understand the output)
2) If cron-job is the better way, should I make each of those above lines a separate cron entry? Or, should I make it one script that just executes?
3) If I should make it a script, what should I name it (.pl, .cgi, .what?) and then what permissions should I assign to it?

Many MANY thanks in advance!

Garrett