How can I perform Bayes training from the Warden command line interface?

Overview

This article provides instructions for configuring and executing Bayes anti-spam training in Warden via the Command Line Interface (CLI) and through automated scheduled tasks. Administrators can train spam, ham, and junk classifications across domains or individual mailboxes, as well as manage token expiration and database statistics.

Command-Line Bayes Training

Administrators can initiate manual Bayes training using the following base command:

warden --task=antispam:train

For comprehensive documentation, refer to the official CLI training guide.

Training Operations Reference

The following examples demonstrate common training operations. Replace placeholder values with your environment-specific domains or mailboxes as needed.

// train spam for all domains
warden --task=antispam:train --oper=train_spam --domains=all

// train ham for all domains
warden --task=antispam:train --oper=train_ham --domains=all

// train junk for all domains
warden --task=antispam:train --oper=train_junk --domains=all

// train spam for specific domains
warden --task=antispam:train --oper=train_spam --domains=example1.com,example2.com

// train ham for specific domains
warden --task=antispam:train --oper=train_ham --domains=example1.com,example2.com

// train spam for specific mailboxes
warden --task=antispam:train --oper=train_spam --mailboxes=test@example1.com,test@example2.com 

// train junk for specific mailboxes
warden --task=antispam:train --oper=train_junk --mailboxes=test@example1.com,test@example2.com 

// train ham for specific mailboxes
warden --task=antispam:train --oper=train_ham --mailboxes=test@example1.com,test@example2.com 

// train ham for a specific mailbox using the last 30 days of unread mail with a max size of 1000 KB. 
warden --task=antispam:train --oper=train_ham --mailboxes=test@example.com --max_days=30 --max_size=1000

// force expire of old tokens out of the database
warden --task=antispam:train --oper=force_expire

// get training statistics
warden --task=antispam:train --oper=statistics

// delete all bayes training data from the database
warden --task=antispam:train --oper=reset_training

Scheduled Bayes Training

Bayes training can be automated through the Warden web interface or configured via CLI:

  • Web Interface: Navigate to **Settings > Anti-spam Training > Training Settings**.
  • Command Line: Use the following base command:
warden --task=antispam:training

For comprehensive documentation, refer to the official scheduled training guide.

Scheduling Configuration Reference

The following examples demonstrate how to configure training intervals, scope, and execution behavior:

// set the training domains to specific domains only
warden --task=antispam:training --training_domains=example.com,example2.com

// turn off ham training
warden --task=antispam:training --train_ham=0

// set the training to daily at 3:00 AM
warden --task=antispam:training --training_interval=daily --training_hour=3

// set the training to weekly every Sunday at 3:00 AM
warden --task=antispam:training --training_interval=weekly --training_day_of_week=0 --training_hour=3

// set the training to monthly on the 3rd of each month at 3:00 AM
warden --task=antispam:training --training_interval=monthly --training_day_of_month=3 --training_hour=3

// set the training training_max_size to 1000 KB
warden --task=antispam:training --training_max_size=1000

// turn off the Bayes training cron task
warden --task=antispam:training --training_interval=disabled

// reset training_interval to its default value
warden --task=antispam:training --default_option=training_interval

// reset all settings to their default values
warden --task=antispam:training --default=yes

// run the Bayes training cron task immediately
warden --task=antispam:training --run_task=yes

Troubleshooting & Verification

To verify training progress, review database token status, or confirm that scheduled tasks are executing correctly, use the following command:

warden --task=antispam:train --oper=statistics

If training data becomes corrupted or requires a complete rebuild, execute the reset operation to clear all Bayes tokens from the database before retraining.

  • sa-learn, bayes, training
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How can I install or upgrade the extension?

We provide free installation and configuration for all our paid licenses. Open a support ticket...

How can I add stronger Postfix restrictions so that the bulk of spam is rejected at the SMTPD level before it gets processed by Amavis?

Overview Warden enables administrators to enforce stricter Postfix SMTPD restrictions. These...

How can I change the interface language of the extension?

Overview This article provides instructions on how to change the interface language within the...

How can I configure greylisting with Warden Anti-spam and Virus protection?

Overview Greylisting is an email filtering mechanism designed to mitigate spam by temporarily...