1

I have a server with several email accounts and limited space.

I set up a cron job to delete emails that are older than 5 days, using this:

find /home/domain/mail/ -type f -name "*vps.domain*" -mtime +5 -delete

It works really well, but cPanel keeps informing wrong account sizes. This is because there's a file in each folder called maildirsize which keeps track of the dir size.

If I delete the file, cPanel says that the size is 0 bytes which is also wrong. The account seems to work OK though and the file is regenerated then.

Is there a way to regenerate these files after running that cron job? Deleting them all and wait for them to be re-generated when the account is used should in theory work, but all accounts will report being 0 bytes and I don't like that.

Nahuel
  • 3,555
  • 4
  • 21
  • 28

1 Answers1

1

Well, apparently there's already a script installed to do that. This is it with some paremeters:

/scripts/generate_maildirsize --verbose --allaccounts --force --confirm

Running that re-generates all maildirsize files. Works great. Appended that to the cron job and everything works fine.

Nahuel
  • 3,555
  • 4
  • 21
  • 28
  • I get an e-mail saying this: "/usr/local/cpanel/bin/jailshell: /scripts/generate_maildirsize: No such file or directory" – coldpumpkin Sep 03 '21 at 11:10