This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
-
palinka
- Senior user

- Posts: 2475
- Joined: 2017-09-12 17:57
Post
by palinka » 2018-07-22 19:18
I just ran across this useful script and I thought it would be good to share.
Save as .cmd and run in task scheduler. I run this on both log files (for 10 days) and backups (for 3 days).
Code: Select all
forfiles /p "C:\Program Files (x86)\hMailServer\Logs" /s /m *.* /D -10 /C "cmd /c del @path"
/s is the switch to add subfolders, which I don't have any, but I left it there anyway. Doesn't hurt.
One thing is while running on logs - I could not get the script to work manually due to UAC and the fact the folder is protected, but setting task scheduler to run as SYSTEM worked fine.
-
jimimaseye
- Moderator

- Posts: 8917
- Joined: 2011-09-08 17:48
Post
by jimimaseye » 2018-07-22 19:44
You could incorporate the cleanup in your nightly backup as suggested here:
viewtopic.php?f=21&t=28139 (scroll down the bottom of the first post to the section "
LOG FILES"). That one looks up and determines where the log files are making the script independent of configuration.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
-
palinka
- Senior user

- Posts: 2475
- Joined: 2017-09-12 17:57
Post
by palinka » 2018-07-22 22:14
I read the entire thread (before posting this topic, actually).. I especially like the email notification. I will install those scripts sooner or later.
What I posted here is for the novice like me.

And it is working.

-
jimimaseye
- Moderator

- Posts: 8917
- Joined: 2011-09-08 17:48
Post
by jimimaseye » 2018-07-22 22:26
Yep. It's a good option. My suggestion was offering people by suggestion a place to run it inclusive with the backup scripts (irrespective of whether they choose compress as my offering or delete of logs as you have offered. Some might want to combine both methods of deleting very old and compressing more recent).
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
-
mattg
- Moderator

- Posts: 21270
- Joined: 2007-06-14 05:12
- Location: 'The Outback' Australia
Post
by mattg » 2018-07-23 01:17
And yet under Australian law, I need to keep my logs for 5 years, so I ZIP mine each month with a script
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
-
palinka
- Senior user

- Posts: 2475
- Joined: 2017-09-12 17:57
Post
by palinka » 2018-07-23 21:13
mattg wrote: ↑2018-07-23 01:17
And yet under Australian law, I need to keep my logs for 5 years, so I ZIP mine each month with a script
I'm an outlaw already...
