I have a small PHP file which I use to generate a txt sitemap. Currently, I'm manually chmoding the sitemap.txt to 666 permissions, running the script, then chmodding back to 664. I want to automate this to run using a cron job, but it will only work by leaving the file at 666 permissions, which is a bit of a security risk. I tried using chmod("sitemap.txt", 0666); within the script itself, but this generates the following error: Warning: chmod() [function.chmod]: Operation not permitted I think this may be related to ownership, but I'm sure there's some way of chmodding the txt file from within the PHP script.