Here's my version of backing up and clearing the log files on a nightly basis (mostly because I hate having to sift through long log files).
I created a new directory called backup_log in my root directory (/home/username/backup_log) to store the nightly log backups. To help keep things organized in the backup_log folder I'll dynamically create a subfolder each time the script is run to hold the final zipped files. This is the script I ended up with (I'm sure it could be improved upon but at least it works).
backup_log.sh
======================================================
#!/bin/sh
# Set the backup date to be appended to the filename
date=`date +%Y_%m_%d`
# create subfolder with the backup date in the backup_log directory
cd /home/username/backup_log
mkdir $date
cd /home/username/railsapp/log/
# Copy Production, Server and FastCGI.crash logs
cp production.log production_$date.log
cp server.log server_$date.log
cp fastcgi.crash.log fastcgi.crash_$date.log
# Move the copied logs to home/username/backup_log directory
mv production_$date.log /home/username/backup_log/$date
mv server_$date.log /home/username/backup_log/$date
mv fastcgi.crash_$date.log /home/username/backup_log/$date
# gzip the logs
/usr/bin/gzip /home/username/backup_log/$date/production_$date.log
/usr/bin/gzip /home/username/backup_log/$date/server_$date.log
/usr/bin/gzip /home/username/backup_log/$date/fastcgi.crash_$date.log
# clear the logs in the rails application
cd /home/username/railsapp && /usr/local/bin/rake log:clear
exit
======================================================
You can copy and paste this into your text editor and name it backup_log.sh and store this in your root directory as well (/home/username/). You'll need to make sure that it has the correct permissions so do a chmod 755 backup_log.sh in your terminal. To test it out simply run ./backup_log.sh in your terminal session. You should now have a dated subfolder in your backup_log directory that contains the dated and zipped log files. Also check your log files in your rails application to verify that they have been reset as well.
Once you have a working script you can set up a cron job to automate the backup. For my purposes I have the cron run the script every night at midnight. So my cron job looks something like this:
0 0 * * * /home/username/backup_log.sh
To set up your cron job, go to your cPanel and choose cronjobs in the advanced panel. Choose the Advanced (Unix Style) button and enter your necessary time requirements and the path to your backup_log.sh script. For a brush up course on cron jobs you can refer to this site:
http://www.linuxhelp.net/guides/cron/Anyways I hope that helps anybody looking for help.