Running Ubuntu web server. I have a PHP script that creates a sitemap file based on database entries.
If I run the file directly, it works and creates the sitemap.xml file as expected.
I'm trying to set this up in a cronjob so that it will update automatically, but when I run the script through ssh directly it appears to run but doesn't actually create or update the sitemap.xml file.
The php script outputs a line of text that looks like this:
https://www.example.com/sitemap.xml updated : 0.0020385026931763 seconds
When I run it via ssh, the output appears with the correct site name and the note that it's been updated, but the file doesn't appear or isn't updated if it already exists. I've tried running it as root and using sudo, and it's not working.
I'm not even sure where to start troubleshooting this.
The code is: