Extra .xac and .log files
Jean-David Beyer
jdbeyer@exit109.com
Fri, 22 Jun 2001 05:54:40 -0400
Dave wrote:
>
> I've just started using gnucash and am quite impressed with it! I've got a
> question about the extra files produced though.
>
> I presume that the extra .xac and .log files are backups and logs
> respectively, and are safe to delete (so long as I've got a backup of the main
> file!) Is there any way to stop them being produced? Would this be a really
> bad idea for some reason? Can I influence where they're created? Currently
> they make it more difficult to see what's going on in the default directory
> (ie along with the main file itself). Plus, they ignore my umask settings and
> are automatically 644 - not really a problem but I'd like fine control over
> this.
>
I am surprised they ignore your umask. If your umask is 027, for
example, I would be surprised if they were other than 640.
What I do is have a crontab setting like this:
02 04 * * * /home/jdbeyer/GnuCash/GAWK.cron
What thes does is that at 2 minutes after 4AM everyday, I am going to
remove all files in this directory (other than GAWK.cron and
GAWK.script) that are over a week older than my current data file
(whose name is JeanDavid).
In my /home/jdbeyer/GnuCash directory is a script, as follows:
#!/bin/bash
cd /home/jdbeyer/GnuCash
sh <<EOF
`ls -lt | /bin/gawk -f /home/jdbeyer/GnuCash/GAWK.script`
EOF
cd ..
/bin/mail jdbeyer -s "Cleaned ~/GnuCash" <<EOF
You might want to check it.
EOF
and GAWK.script reads:
# GnuCash cleanup script.
# This (g)awk script rummages around in ~jdbeyer/GnuCash and removes
# all files a week older than the current (JeanDavid) file. I.e.,
# we return the current file and a week's previous .log and .xac
files.
# There may be a bug in the line: total *= 365.
# It will be off by all the leap years since 0000, but since
# we should never have backup files that much older than the
# current file, I think it should be OK.
# Get into ~jdbeyer/GnuCash and run:
# `ls -lt | gawk -f GAWK.script`
function filedate(Month, Day, YearTime, leap, total, timestamp)
{
if(index(YearTime, ":") == 0) {
total = YearTime;
}
else {
timestamp = systime();
total = strftime("%Y", timestamp)
}
if((total % 4) == 0) {
leap = 1
} else {
leap = 0
}
total *= 365;
total += leap;
if(Month == "Jan") total += 0;
if(Month == "Feb") total += 31;
if(Month == "Mar") total += 59;
if(Month == "Apr") total += 90;
if(Month == "May") total += 120;
if(Month == "Jun") total += 151;
if(Month == "Jul") total += 181;
if(Month == "Aug") total += 212;
if(Month == "Sep") total += 243;
if(Month == "Oct") total += 273;
if(Month == "Nov") total += 304;
if(Month == "Dec") total += 334;
total += Day;
return total;
}
$1 != "total" && !/GAWK.*/ && $9 == "JeanDavid" {newest = filedate($6,
$7, $8);
#print newest;
}
$1 != "total" && !/GAWK.*/ && (length($9) != 0) && $9 != "JeanDavid"
{#print filedate($6, $7, $8), $6, $7, $8, $9;
if(filedate($6, $7, $8) < (newest - 7))
print "rm", $9 " ;"
}
--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ Registered Machine 73926.
/( )\ Shrewsbury, New Jersey http://counter.li.org
^^-^^ 5:45am up 14 days, 18:39, 3 users, load average: 4.26, 3.04,
2.40