Create a Delete Email Cron Job?

JessC

Member
Oct 3, 2019
12
2
3
Philippines
cPanel Access Level
Reseller Owner
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
Code:
#!/bin/sh
find /home/example/mail/example.com/it/cur -type f -mtime +90 -exec rm {} \;
3. Cron Job setting is:
Code:
/usr/local/bin/php /home/example/cron-jobs/deletemail_it.sh
Result:
1. Once the cron job runs, I received this email
Code:
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
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
807
160
168
New Jersey
cPanel Access Level
DataCenter Provider
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.
 

JessC

Member
Oct 3, 2019
12
2
3
Philippines
cPanel Access Level
Reseller Owner
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 now
 

JessC

Member
Oct 3, 2019
12
2
3
Philippines
cPanel Access Level
Reseller Owner
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