Quantcast
Viewing all articles
Browse latest Browse all 4520

How to Delete All Files from a Directory Daily Using Cron?

I need to delete all files from a specific folder every day using a cron job. My current crontab entry looks like this:

0 22 * * * rm -rf /var/www/abcd/app/Management/application/session/*

However, this does not always work, especially when there are a large number of files in the folder. Sometimes I get the error, as i redirect the error into file using this crontab:

0 22 * * * rm -rf /var/www/abcd/app/Management/application/session/* >> /home/ubuntu/errorgetter.log 2>&1

This is the error:

/bin/sh: 1: /bin/rm: Argument list too long

Note: I created crontab -e as root user, so there is no permission issue to delete it.

Now How will i do this?


Viewing all articles
Browse latest Browse all 4520

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>