On Sat, 15 Apr 2006, Bruce Momjian wrote:
ls -tp /pg_xlog/ | grep -v "backup\|/" | head -1
which seems to work fairly well. Looks like that thread is here:
http://archives.postgresql.org/pgsql-admin/2005-10/msg00173.php
What does the -p and \| pipe check do? We don't have named pipes in
that directory, do we?
Also, what happens if the log switch happens, and some data change is
written to the new WAL file in the first second, but nothing happens to
the database after that for a minute? Your test would still show the
old log file.
The -p shows forward slashes after directories and the \| acts as an or and
the / following that just lets us filter directories out. I added that
because I used to find the archive_status directory winning the ls -t from
time to time.
Now about your what if question. I don't know if there is a way to get past
the mtime granularity. If I understand your scenario correctly, you indicate
that the previous log is written to and the new log is switched in during the
same mtime second. I did a quick test on linux to see how that operates:
touch AA AB
This yields both files with the same mtime.
ls -tp |head -1
yields AA as you suggested it would.
The following seems to do the trick if we can rely on alphabetizing to
properly decide the winner of a tie:
ls -tp | head -2 | sort -r | head -1
So, with my previous example, it would look like:
ls -tp /pg_xlog/ | grep -v "backup\|/" | head -2 | sort -r | head -1
--
Jeff Frost, Owner <[EMAIL PROTECTED]>
Frost Consulting, LLC http://www.frostconsultingllc.com/
Phone: 650-780-7908 FAX: 650-649-1954
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly