Don't know your OS, but for a MAC: https://discussions.apple.com/thread/2115539?start=0&tstart=0
Cron job to remove storage files
Users on my site can upload a profile picture and they can preview the picture before selecting it. Im using Intervention/image URL manipulation to serve the pics so in order to let the users see what their pics will actually look like on the site, Im sending them via ajax to my server, saving them in a temp directory in storage, and then setting the src on the profile to the temporary image url. Works great.
However, I cant find a good way to keep the temp directory clean. Ideally, I would like to do a cron job to wipe out all the files older than 10 minutes every ten minutes or so, but Im having permission issues. Although storage itself is owned by my user, the created files are all owned by www-data so my command to delete them fails with a permission denied error. How can I fix this? Is there a better way to handle this?
Please or to participate in this conversation.