Create a Delete Email Cron Job?
Hi,
I'm trying to setup cron job to delete emails. I've been searching in this forum and tried to replicate what in there.
Here's what I setup:
1. Created a folder named cron-jobs. The location is under home/user/cron-jobs. And the permission is 0755.
2. I created a file named deletemail_it.sh. The permission is 0744
The code is
3. Cron Job setting is:
Result: 1. Once the cron job runs, I received this email
2. Once I checked the mailbox. The emails are still there Note: The mailbox contains 3 emails dated 2018. Did I configure wrong somewhere in my settings? Thanks in advance
#!/bin/sh
find /home/example/mail/example.com/it/cur -type f -mtime +90 -exec rm {} \;3. Cron Job setting is:
/usr/local/bin/php /home/example/cron-jobs/deletemail_it.shResult: 1. Once the cron job runs, I received this email
find /home/example/mail/example.com/it/cur -type f -mtime +90 -exec rm {} \;2. Once I checked the mailbox. The emails are still there Note: The mailbox contains 3 emails dated 2018. Did I configure wrong somewhere in my settings? Thanks in advance
-
You are trying to execute a bash script using PHP, that won't work. Since the script has execute permissions as the user, just put: /home/example/cron-jobs/deletemail_it.sh or you could do: bash /home/example/cron-jobs/deletemail_it.sh but its not necessary Otherwise, it should work. 0 -
You are trying to execute a bash script using PHP, that won't work. Since the script has execute permissions as the user, just put: /home/example/cron-jobs/deletemail_it.sh or you could do: bash /home/example/cron-jobs/deletemail_it.sh but its not necessary Otherwise, it should work.
Thanks Sir. It works now0 -
Hi Sir, Why do I have this error in other domain? /home/s1076714/cron/deletemail.sh: line 2: /home/s1076714/mail/example.com.au/someusr.cubio/cur: is a directory 0 -
Hi Sir, Why do I have this error in other domain? /home/s1076714/cron/deletemail.sh: line 2: /home/s1076714/mail/example.com.au/someusr.cubio/cur: is a directory
Nevermind, I find my mistake.0 -
Glad to see you were able to get the issue resolved @JessC 0
Please sign in to leave a comment.
Comments
5 comments