We try to keep our code clean and commented but every once in a while we do some maintenance that falls into what I call “Organizing the spice drawer.” It’s not something that has to be done and the amount of time lost by not doing it is small, but it’s just one sign of a well organized shop. The same applies to our server, backups, and the office in general. This time of year is perfect for these endeavors because there’s not usually much else going on.
Log files
We set up the server logs to automatically archive and then delete themselves so we don’t have to worry about them. We do have some custom logging programs that write data to the MySQL database. They’re not huge, but we’ll never use more than a year’s worth, so they get manually cleaned from time to time. I just deleted 45,000 records from one database.
/tmp
It’s a good idea to check what’s in here from time to time. We has some session cookies that weren’t being properly expired so we wrote a cron job to remove them. There were also some files created by a shell script that weren’t getting deleted, so we adjusted the script to remove them.
php.ini
Every once in a while, it’s a good idea to review the settings in the php.ini file to make sure you are happy with them. In our case, we were getting warnings from two deprecated commands, register_long_arrays and magic_quotes_gpc and we decided to turn them both to Off since we don’t have any code that relies on them and the code that triggered the warnings is in WordPress. The WprdPress code works fine if the settings are Off.
BAK files and databases
Before we do any major change to a file or database we make a backup copy. These usually get deleted when we’re happy with the result, but sometime they stay around when they aren’t needed any more. For the database, I make a complete dump of the database to a .sql file and then remove databases that are backups. If I ever need them, I’ve got the backup in storage.
Orphans
Our websites have been up since 1998 and we sometimes end up with files that are no longer referenced. If we suspect that a file is not used anymore we grep for its name in the web directory and if it’s not found we put a line of code in it that writes to the server when it is referenced.
$refer=mysql_real_escape_string($_SERVER['HTTP_REFERER']);
error_log("Accessing Orphan File with referrer $refer");
If we reference it from one of our pages, the referrer will be our site. If not, then either it’s being accessed by a spam-bot or another website that has an old link to us. Either way, we can then deal with it.
Spambots
Lately, spambots have been hitting just about every page with a submit button on it. They can’t do anything on those pages but I’ve started logging their attempts using the method described in Orphans above. If it’s a real problem we may start requiring CAPTCHAs or simple radio buttons that default to “I am a robot, please ignore this request”.
Error logs
When we updated to the latest version of PHP our database access method, PEAR, was deprecated. That generated literally thousands of error messages. Over time we updated the code, but there were still lots of errors generated for pages that aren’t accessed that much. With so many error messages, it’s hard to see real errors. So we spent a half day finishing off the update. Now the error logs only show the log messages that we want it to show and we can quickly check for errors.
Wikis
We have a wiki for office procedures, how-to’s for ordering supplies, adding users, version numbers for our products, etc. This is the kind of thing that can quickly become out of date if it is not updated regularly. A couple of times a year, we review the wiki and make updates for changes to our processes that were made, but didn’t make it into the wiki.
Office Electronics
Do we really need 12 VGA monitor cables? Three turntables? The 12 year old computer that only runs OS9? The box of old hard drives—the largest of which is 5GB? We don’t keep a lot of stuff we don’t use but things get shoved under desks and put in boxes on the bottom shelf and forgotten about. Every once in a while we make a big pile of stuff and take it to the electronics recycling center. I have yet to regret throwing away anything.
Books
We got rid of a complete shelf of books. I will never need the manual for Photoshop 4 or Flash 5. In fact, I haven’t used a manual for years, relying instead on the web for the answers to most of my questions. My guess is next year the other two shelves of books will be gone.