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:

php /srv/users/server/apps/example/public/sitemapxml.php

  • User running the cron job has appropriate permissions for where the file gets output? – ivanivan May 28 at 18:33
  • Go have a chat with the script's developer about its lack of error messages. – Michael Hampton May 28 at 18:45
  • @ivanian - yes. I've tried running the script direct in terminal as root and it's still giving the same issue – Aninemity May 28 at 19:05
  • @MichaelHampton - I wrote the script. If there was an error it shouldn't be returning the output which it is. – Aninemity May 28 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.