How do we automatically cleanup failed Wordpress uploads that are in /tmp ? Say delete everything that is 3+ days old.

  • 1
    Most hosting environments automatically clear old items out of /tmp on their own schedule... You theoretically shouldn't need to do anything. Do you wish to remove items specifically added by Wordpress and leave the other files alone? Or are you wishing to clear the entire /tmp directory of items 3+ days old? If you do wish to clear the entire directory, what don't you like about your server's current handling of the /tmp directory? – bosco May 2 '13 at 16:28
  • This is our own private server, not a hosting provider, so we need to do our own housekeeping. And we cannot just delete everything as other applications also use /tmp to host their transient files. – J. Chin May 2 '13 at 16:31
  • Your own proprietary server? Did you write it in Node.js or some such? Because its typical for Apache and NGINX to clear /tmp on a cron schedule, and PHP should remove anything it added and left in the /tmp directory at the end of script execution (even for failed uploads)... While you could use the WP Cron Functions to manually clean up tmp, I would argue that if your /tmp directory isn't already clearing on a regular schedule something is funky in your server, cron, or PHP config and you should attack the issue at its source... – bosco May 2 '13 at 16:44

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.