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?