You're being very patient with me. Thank you.
I'm now running the program though SSH. When I run it for 500 pages as a test, it runs perfectly. I then ran it for 25,000 pages maximum (as we have about 22,000). I ran it twice with the same results. Both times it ran for 19 minutes and then stopped. Nothing was output to the sitemap.
On the following page, I've placed (a) the permissions for the various files so you can see if that's right and (b) the output from running the program for 19 minutes:
[ External links are visible to forum administrators only ]
I then set it to save every 300 seconds. When I do that, the job just stops sooner and then restarts from the beginning.
Thanks