I am trying to create a cron job that deletes any temp files after certain periods of time.

In crontab I have this:

@hourly /var/www/magento/cache.sh

And in cache.sh there is the following:

find /var/www/magento/var/cache/ -type f -mmin +120 -exec rm {} \;
find /var/www/magento/var/session/ -type f -mmin +120 -exec rm {} \;
find /var/www/magento/var/report/ -mtime +7 -exec rm -f {} \;
find /var/www/magento/var/tmp/ -mtime +1 -exec rm -f {} \;

However the e-mail output is this:

find: missing argument to `-exec'
find: missing argument to `-exec'
find: missing argument to `-exec'
rm: cannot remove `/var/www/magento/var/tmp/': Is a directory

I'm quite new to cron jobs, does anybody know what I am doing wrong here?

Thanks in advance :)

  • I'm voting to close this question as off-topic because this is not really about Magento
    – Marius
    Mar 2, 2015 at 14:08

1 Answer 1


sudo find /var/www/html/erp/var/log/ -type f -exec rm -rf {} +

  • Care to expand?
    – Alexander
    Sep 11, 2014 at 11:39
  • this wil also work, find /var/www/html/erp/var/log/ -type f -exec rm {} \; i have doubt on the -mmin +120
    – Jignesh
    Sep 11, 2014 at 12:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.