Skip to content

Instantly share code, notes, and snippets.

@dmdeller
Created October 17, 2009 21:09
Show Gist options
  • Save dmdeller/212457 to your computer and use it in GitHub Desktop.
Save dmdeller/212457 to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
# execute as nightly cronjob
# redirect to /dev/null if you don't want get mailed errors because WoW is running
# use with Elephant (or similar) addon that automatically enables writing to WoWChatLog.txt
$source_path = "/Applications/Games/World of Warcraft/Logs";
$dest_path = '/Users/david/Documents/Logs/WoW';
if (!file_exists($source_path) || !is_dir($source_path))
{
echo "Bad logs path\n";
exit(1);
}
if (shell_exec('ps -A | grep "World of Warcraft" | grep -v grep | wc -l | tr -d " "') != 0)
{
echo "Not while WoW is running kthx\n";
exit(1);
}
if (file_exists($source_path.'/WoWChatLog.txt'))
{
if (!file_exists($dest_path))
{
mkdir($dest_path);
}
$i = 0;
while (true)
{
$try_file = $dest_path.'/'.date('Y-m-d').($i > 0 ? '-'.$i : '').'.txt';
if (!file_exists($try_file))
{
rename($source_path.'/WowChatLog.txt', $try_file);
break;
}
$i++;
}
}
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment