elcidofaguy
Well-known member
- Joined
- Jan 13, 2015
- Messages
- 1,281
- Points
- 113
Greetings All,
I'm trying to figure out the best way to bulk delete emails automatically on my webserver with using a script and cron job.
The closest I've got is the following bash script - following example is to delete emails in cur folder older than 60 mins (so that I can test it before setting it for a number of days):
Noting for days I'm using -mtime instead of -cmin. Instead of -cmin I've also tried -mmin...
The reason I'm doing this as a script is so that the various folders can be addressed e.g. spam, cur, new etc for each given email address in one go...
I've setup a cron job and as a test set it to execute every minute and unfortunately its not working. The CRON looks like:
I really appreciate if anyone out there can see what is wrong... I'm not sure if its a shared web hosting issue which could be the problem.... I've also set the permission on the file to 755... and still no luck....
Alternatively I'm tempted to write this using php to parse through each file within the relevant email folder checking file datetime in order to ascertain deletion and running that via cron - but it seems long winded approach when this could be done in a single line using a bash shell script...
Appreciate any help, especially if you have done something like this before...
Cheers,
Sid
I'm trying to figure out the best way to bulk delete emails automatically on my webserver with using a script and cron job.
The closest I've got is the following bash script - following example is to delete emails in cur folder older than 60 mins (so that I can test it before setting it for a number of days):
Code:
#!/bin/bash
find -P /homelocn/user/folder/domain.com/email/cur -type f -cmin '+60'
The reason I'm doing this as a script is so that the various folders can be addressed e.g. spam, cur, new etc for each given email address in one go...
I've setup a cron job and as a test set it to execute every minute and unfortunately its not working. The CRON looks like:
Code:
* * * * * /homelocn/folder/myscript.sh
Alternatively I'm tempted to write this using php to parse through each file within the relevant email folder checking file datetime in order to ascertain deletion and running that via cron - but it seems long winded approach when this could be done in a single line using a bash shell script...
Appreciate any help, especially if you have done something like this before...
Cheers,
Sid