Posted by Tim Connor
Fri, 13 Apr 2007 17:48:00 GMT
MAILTO=me@mydomain.com
# minute (0-59),
# | hour (0-23),
# | | day of the month (1-31),
# | | | month of the year (1-12),
# | | | | day of the week
# | | | | |
*/5 * * * * wget -q -O /dev/null http://mydomain.com >/dev/null
@hourly /home/myuser/clear_timocracy_sessions.sh
@daily /home/myuser/rotate_timocracy_logs.sh
Grabs the site every 5 minutes to keep the fcgi alive on Dreamhost, and calls scripts that clear the sessions and rotate the logs
h3. clear_timocracy_sessions.sh
#!/bin/bash
/home/mysuser/mydomain/script/runner -e production "CGI::Session::ActiveRecordStore::Session.destroy_all( ['updated_at <?', 1.day.ago])"
Clears out sessions older than a day.
h3. rotate_timocracy_logs.sh
#!/bin/bash
cd /home/myuser/mydomain
/usr/sbin/logrotate -s log/logrotate.status config/logrotate.conf -f; touch public/dispatch.fcgi
Calls
logrotate and then updates the timestamp on dispatch.fcgi, so Apache will create new worker processes
h3. config/logrotate.conf
"log/*.log" {
compress
weekly
delaycompress
missingok
notifempty
rotate 52
create
}
Archive weekly, keeping a years worth of logs. delaycompress – wait to gzip them, till the next week, both for ease of reading the most recent and so there is time for the fcgi threads to get killed off, since they are pointing at the old log.