Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k
Source Link
Chris
  • 133
  • 4

Optimise a shell script / command to delete files

I'm running Magento and it doesn't clean up old session data, so I need to clean it up with a shell script / cronjob:

0,30 * * * * /usr/bin/find /var/www/magento/var/session -name 'sess_*' -type f -mtime +1 -exec rm {} \;

But that script takes usually some minutes to delete the old files. I'm wondering whether I need to search for the files since in this directory are only files that start with "sess_" - but I still need to traverse those files somehow, right?

(around 50.000 files per day are created in this directory)