I have a cron job that runs a PHP script and creates files (images). But the cron job is running as me (being me my own username), not apache, nobody, httpd, www... and all the files created belongs to this user.
If I run the the same script through a browser, it runs as apache. I've tested it with
whoami and checked the file permissions.
The problem is that if I develop an web-interface to remove files (which is how users/admin will be able to manage the images), it will run as apache and it won't be able to remove the files, as apache is not the owner nor belongs to the same group as me.
What would be the correct way to deal with this?
- Add me to apache group or the other way around?
- Save the files with permission 0777? This looks 'ugly'
- Try to run the cron job as apache? How?