SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Use this forum for discussions about SpamAssassin and anti-spam in general.
Post Reply
User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jim.bus » 2020-05-11 09:52

I just installed SpamAssassin For Windows.

I ran the sa-update.exe program to update SpamAssassin with current rules update in a Windows Command Prompt.

sa-update -v --nogpg

This did a successful retrieval of SapamAssassin updates.

I then set up a Task Schedule to automatically run this update each day.

Task Schedule Actions are:

Action 1: net stop SpamAssassin
Action 2: "C:\Program Files\JAM Software\SpamAssassin for Windows\sa-update.exe" -v --nogpg
Action 3: net start SpamAssassin

The scheduled Task gets a Successful completion but Action 2 gets a Return Code 2147942401 with a Windows Event Id: 201 but still the Task Scheduler History still reports Action2 as successful. Actions 1 and 3 all got Return Code 0.

Windows Event Id: 201 is supposed to mean a Successful Task Action and No Further Action is Required.

However, I cannot determine if this just means that the Task Action fully completed and with no errors or if it means the Tasks Action Completed without any regard to the actual Action, meaning sa-update, completing successfully.

My question then is did the Action sa-update successfully retrieve the Update Rules for SpamAssassin. Now of course since I had run sa-update in Command Prompt there weren't anymore Rules to retrieve since they had just been retrieved under Command Prompt.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

User avatar
jimimaseye
Moderator
Moderator
Posts: 10060
Joined: 2011-09-08 17:48

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jimimaseye » 2020-05-11 10:10

I run the following (shortened) section in a bat file and it works perfectly.

Code: Select all

net stop spamassassin
sa-update.exe -v --nogpg --channelfile UpdateChannels.txt 
if errorlevel 1 then....
Net start spamassassin
(Note that errorlevel 1 is returned even if there are now no updates since the last update).

More details here: https://www.hmailserver.com/forum/viewt ... 21&t=28139

[Entered by mobile. Excuse my spelling.]
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

User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jim.bus » 2020-05-11 13:14

jimimaseye wrote:
2020-05-11 10:10
I run the following (shortened) section in a bat file and it works perfectly.

Code: Select all

net stop spamassassin
sa-update.exe -v --nogpg --channelfile UpdateChannels.txt 
if errorlevel 1 then....
Net start spamassassin
(Note that errorlevel 1 is returned even if there are now no updates since the last update).

More details here: https://www.hmailserver.com/forum/viewt ... 21&t=28139

[Entered by mobile. Excuse my spelling.]
Stupid me. I had planned to try running it as a batch file also but got side tracked. It appears to run correctly with a return code now of 0 for the batch file.

One thing to note though is that at least with the SpamAssassin For Windows I installed on my system, apparently the UpdateChannels.txt file does not seem to exist when installing SpamAssassin. I found when searching for how to update SpamAssassin with sa-update that apparently with the arguments I used it will update the rules also from some kind of standard set (best as I recall reading).

Additionally, when examining the Task History to see if the Task executed successfully, you will only see as the Action that 'cmd.exe' was executed instead of your Batch File. This is of course because batch files need to run as a Command Prompt. But you still code the batch file into the Program entry of the Task Scheduler Action tab. And you need to fill in the 'Start in' field with the Path to the batch file which in my case was C:\Program Files\JAM Software\SpamAssassin for Windows\.

One last thing in order to tell if your Batch file ran correctly without failure, in order to see the progress in the Command Prompt, you can code in a 'Pause' in your Batch File to pause the Batch file execution so you can what the results are. You must also set your Task to run only when user is logged on to be able to see the Command Prompt execution. Once you have verified the Batch File ran properly, you can then change your Task to run 'Whether or not the user is logged on' and remove the 'Pause' from the Batch File otherwise it won't run unattended properly.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jim.bus » 2020-05-13 19:13

SpamAssassin now runs.

But why in hMailAdmin must I specify localhost or IP Address 127.0.0.1 in order to Test. What I would like to do is to use the Hostname of my Local Network so I can access this SpamAssassin installation from another Local Network I have also running hMailServer. I have tried to Test on the other Local Network using the Hostname of my Local Network which has SpamAssassin installed on it and it always fails.

I have Port 783 open on the SpamAssassin Local Network. I have Port 783 for Spamd.exe open for all PCs in my McAffee Firewall running on the computer with SpamAssassin installed on it.

Is the problem that for Test Purposes you can only run Test when SpamAssassin is installed on the same computer as hMailServer. Doesn't make sense to me. At some point I might like to put SpamAssassin on a server computer to be accessed by any computer which may happen to be running hMailServer without having to install SpamAssassin on the computer running hMailServer. At this point, I don't need to but I like to set up installations when possible to be able to be accessed from anywhere without having to change the setup of the Server.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

User avatar
katip
Senior user
Senior user
Posts: 1161
Joined: 2006-12-22 07:58
Location: Istanbul

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by katip » 2020-05-13 20:47

jim.bus wrote:
2020-05-13 19:13
SpamAssassin now runs.

But why in hMailAdmin must I specify localhost or IP Address 127.0.0.1 in order to Test. What I would like to do is to use the Hostname of my Local Network so I can access this SpamAssassin installation from another Local Network I have also running hMailServer. I have tried to Test on the other Local Network using the Hostname of my Local Network which has SpamAssassin installed on it and it always fails.

I have Port 783 open on the SpamAssassin Local Network. I have Port 783 for Spamd.exe open for all PCs in my McAffee Firewall running on the computer with SpamAssassin installed on it.

Is the problem that for Test Purposes you can only run Test when SpamAssassin is installed on the same computer as hMailServer. Doesn't make sense to me. At some point I might like to put SpamAssassin on a server computer to be accessed by any computer which may happen to be running hMailServer without having to install SpamAssassin on the computer running hMailServer. At this point, I don't need to but I like to set up installations when possible to be able to be accessed from anywhere without having to change the setup of the Server.
feel free to change IP nr. to that computer's where SA is running and test, within same LAN though. if that box is on another LAN, this is a network (routing) issue. but should also run fine if set up properly.
even installations on WAN is documentec IIRC.
Katip
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8

User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jim.bus » 2020-05-13 23:30

I am going to make an educated guess as to why SpamAssassin has to be run with hostname localhost or IP Address 127.0.0.1.

Apparently to set up SpamAssasin to run as a Windows Service, jimmimaseye advised to use NSSM to make SpamAssassin run as a Windows Service. Apparently SpamAssassin probably because it is an Apache Product and to install it on Windows we had to use JAM Software compile of SpamAssassin, have to use NSSM to be able to install as a Windows Service otherwise it is not entirely compatible with Windows Services requirements.

The actual service which runs in Windows Services is not SpamAssasin but rather NSSM. I am suspecting it is this which makes it a requirement to access SpamAssasin as localhost on my Windows Computer. hMailServer can't find it under the External Hostname nor even under the Computer Name within my Local Network. It strictly needs localhost or IP Address 127.0.0.1 because anywhere outside of the Computer running SpamAssassin, hMailServer will not be able to locate SpamAssassin by its actual application name. Outside of the running computer, SpamAssassin is probably only identified as NSSM as in my installation of it and not by Spamd.exe.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

User avatar
SorenR
Senior user
Senior user
Posts: 6315
Joined: 2006-08-21 15:38
Location: Denmark

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by SorenR » 2020-05-13 23:54

jim.bus wrote:
2020-05-13 23:30
I am going to make an educated guess as to why SpamAssassin has to be run with hostname localhost or IP Address 127.0.0.1.

Apparently to set up SpamAssasin to run as a Windows Service, jimmimaseye advised to use NSSM to make SpamAssassin run as a Windows Service. Apparently SpamAssassin probably because it is an Apache Product and to install it on Windows we had to use JAM Software compile of SpamAssassin, have to use NSSM to be able to install as a Windows Service otherwise it is not entirely compatible with Windows Services requirements.

The actual service which runs in Windows Services is not SpamAssasin but rather NSSM. I am suspecting it is this which makes it a requirement to access SpamAssasin as localhost on my Windows Computer. hMailServer can't find it under the External Hostname nor even under the Computer Name within my Local Network. It strictly needs localhost or IP Address 127.0.0.1 because anywhere outside of the Computer running SpamAssassin, hMailServer will not be able to locate SpamAssassin by its actual application name. Outside of the running computer, SpamAssassin is probably only identified as NSSM as in my installation of it and not by Spamd.exe.
spamd listens per default only on 127.0.0.1 ... You should be able to change this by using this commandline parameter:
-i [ipaddress], --listen-ip[=ipaddress], --ip-address[=ipaddress]
Tells spamd to listen on the specified IP address (defaults to 127.0.0.1). If you specify no IP address after the switch, spamd will listen on all interfaces. (This is equal to the address 0.0.0.0). You can also use a valid hostname which will make spamd listen on the first address that name resolves to.
SørenR.

Woke is Marxism advancing through Maoist cultural revolution.

User avatar
SorenR
Senior user
Senior user
Posts: 6315
Joined: 2006-08-21 15:38
Location: Denmark

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by SorenR » 2020-05-14 00:20

Forgot this one ... so by running "spamd -A 192.168.0.0/24 -i" you make spamd listen on all interfaces (0.0.0.0) and authorise the 192.168.0.0 subnet.

This is all "book ware" as I have not tried it myself ... Yet :wink:
-A host,..., --allowed-ips=host,...
Specify a list of authorized hosts or networks which can connect to this spamd instance. Single IP addresses can be given, ranges of IP addresses in address/masklength CIDR format, or ranges of IP addresses by listing 3 or less octets with a trailing dot. Hostnames are not supported, only IP addresses. This option can be specified multiple times, or can take a list of addresses separated by commas. Examples:
-A 10.11.12.13 -- only allow connections from 10.11.12.13.

-A 10.11.12.13,10.11.12.14 -- only allow connections from 10.11.12.13 and 10.11.12.14.

-A 10.200.300.0/24 -- allow connections from any machine in the range 10.200.300.*.

-A 10. -- allow connections from any machine in the range 10.*.*.*.

By default, connections are only accepted from localhost [127.0.0.1].
SørenR.

Woke is Marxism advancing through Maoist cultural revolution.

User avatar
SorenR
Senior user
Senior user
Posts: 6315
Joined: 2006-08-21 15:38
Location: Denmark

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by SorenR » 2020-05-14 00:21

jimimaseye wrote:
2020-05-14 00:17
Spamassassin does not run as a service on windows. Nssm is a mechanism to run it as a service.

Spamassassin and nssm must be installed together on whatever computer you choose. You can install them on the same machine as hms or a remote machine.

Hms admin is then told the ip address and port (default 783) of whatever that computer is.

Most run spamassassin on the same machine as hmailserver and so 'localhost' suffices. But if you have installed spamassassin elsewhere then specify it accordingly.

Note: I say this without the hms admin screen in front of me.

[Entered by mobile. Excuse my spelling.]
I use srvany on my server and with Sysinternals TCPView I can see spamd listens on a different interface when I change the parameters.
SørenR.

Woke is Marxism advancing through Maoist cultural revolution.

User avatar
jimimaseye
Moderator
Moderator
Posts: 10060
Joined: 2011-09-08 17:48

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jimimaseye » 2020-05-14 00:23

Spamassassin does not run as a service on windows. Nssm is a mechanism to run it as a service. 

Spamassassin and nssm (if choosing the windows version) must be installed together on whatever computer you choose. You can install them on the same machine as hms or a remote machine. Remote machine can be Linux version of spamassassin if desired.

Hms admin is then told the ip address and port (default 783) of whatever that computer is. 

Most run spamassassin on the same machine as hmailserver and so 'localhost' suffices. But if you have installed spamassassin elsewhere then specify it accordingly.

From what soren is suggesting you may need to tell that remote machine to accept remote connections (instead of just from localhost).

Note: I say this without the hms admin screen in front of me. 

[Entered by mobile. Excuse my spelling.]
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

User avatar
SorenR
Senior user
Senior user
Posts: 6315
Joined: 2006-08-21 15:38
Location: Denmark

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by SorenR » 2020-05-14 00:48

hMailServer runs on 192.168.0.5
SpamAssassin runs on 192.168.0.5

Code: Select all

spamd.exe -A 192.168.0.5 --ip-address --allow-tell --max-children=15 --syslog=C:\spamassassin\logs\spamd.log
hMailAdmin.png
SørenR.

Woke is Marxism advancing through Maoist cultural revolution.

User avatar
SorenR
Senior user
Senior user
Posts: 6315
Joined: 2006-08-21 15:38
Location: Denmark

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by SorenR » 2020-05-14 01:10

changed parameters to allow the entire 192.168.0.0 subnet to use SpamAssassin.

Code: Select all

spamd.exe --allowed-ips=192.168.0.0/24,127.0.0.1 --ip-address --allow-tell --max-children=15 --syslog=C:\spamassassin\logs\spamd.log
SørenR.

Woke is Marxism advancing through Maoist cultural revolution.

User avatar
mattg
Moderator
Moderator
Posts: 22437
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by mattg » 2020-05-14 03:27

jim.bus wrote:
2020-05-13 19:13
Is the problem that for Test Purposes you can only run Test when SpamAssassin is installed on the same computer as hMailServer.
Nope

I run Spamassassin on my Ubuntu webserver
Test from hMailserver works fine pointing to the IP address of my webserver
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jim.bus » 2020-05-14 13:31

mattg wrote:
2020-05-14 03:27
jim.bus wrote:
2020-05-13 19:13
Is the problem that for Test Purposes you can only run Test when SpamAssassin is installed on the same computer as hMailServer.
Nope

I run Spamassassin on my Ubuntu webserver
Test from hMailserver works fine pointing to the IP address of my webserver
I believe you don't have the problem because you are running on Ubuntu. I run on Windows 10. If I remember the documentation correctly I believe SpamAssassin was designed for systems that were more Lenix based. Ubuntu is a distribution of Lenix. SpamAssassin apparently is not fully compatible as a Windows Service and as per a jimmisaeye tutoroial needs to be installed as a service called NSSM and it is NSSM which is installed as the Windows Service. From the SpamAssassin website to install SpamAssassin for Windows, I had to download a version of SpamAssassin from JAM Software. Apparently that version specifies spamd.exe to listen by default on only IP Address 127.0.0.1. However, apparently by specifying options, I can have it listen on all IP Addresses if I am interpreting what SorenR and the documentation says correctly by specifying overriding line command options.

So apparently the problem for me is because I am using SpamAssasin for Windows and it defaults to only listen on IP 127.0.0.1. This poses an additional concern as I believe I read in the documentation that it would be possible for an outsider to read messages passed to SpamAssassin. So, if I want to run SpamAssassin on another computer, I need to look at the Authentication and Encryption Options of spamd.exe. Running it on the same computer as hMailServer would, I believe, not necessitate having to use Authentication and Encryption Options as SpamAssassin would already be behind my Router and Computer McAffee Firewalls and protected that way because it would only be listening on Port 783 for IP 127.0.0.1 which is only used internally in the hMailServer computer.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

User avatar
SorenR
Senior user
Senior user
Posts: 6315
Joined: 2006-08-21 15:38
Location: Denmark

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by SorenR » 2020-05-14 13:54

jim.bus wrote:
2020-05-14 13:31
mattg wrote:
2020-05-14 03:27
jim.bus wrote:
2020-05-13 19:13
Is the problem that for Test Purposes you can only run Test when SpamAssassin is installed on the same computer as hMailServer.
Nope

I run Spamassassin on my Ubuntu webserver
Test from hMailserver works fine pointing to the IP address of my webserver
I believe you don't have the problem because you are running on Ubuntu. I run on Windows 10. If I remember the documentation correctly I believe SpamAssassin was designed for systems that were more Lenix based. Ubuntu is a distribution of Lenix. SpamAssassin apparently is not fully compatible as a Windows Service and as per a jimmisaeye tutoroial needs to be installed as a service called NSSM and it is NSSM which is installed as the Windows Service. From the SpamAssassin website to install SpamAssassin for Windows, I had to download a version of SpamAssassin from JAM Software. Apparently that version specifies spamd.exe to listen by default on only IP Address 127.0.0.1. However, apparently by specifying options, I can have it listen on all IP Addresses if I am interpreting what SorenR and the documentation says correctly by specifying overriding line command options.

So apparently the problem for me is because I am using SpamAssasin for Windows and it defaults to only listen on IP 127.0.0.1. This poses an additional concern as I believe I read in the documentation that it would be possible for an outsider to read messages passed to SpamAssassin. So, if I want to run SpamAssassin on another computer, I need to look at the Authentication and Encryption Options of spamd.exe. Running it on the same computer as hMailServer would, I believe, not necessitate having to use Authentication and Encryption Options as SpamAssassin would already be behind my Router and Computer McAffee Firewalls and protected that way because it would only be listening on Port 783 for IP 127.0.0.1 which is only used internally in the hMailServer computer.
Could you just go back and read my last 3 posts? You need 2 extra parameters on the spamd.exe commandline to break the "localhost conundrum". I spend 3 hours investigating this issue last night triggered by your conclusion and my own curiosity. :roll:

If your service launcher for spamd cannot honor parameters on the spamd commandline I suggest you get another!
SørenR.

Woke is Marxism advancing through Maoist cultural revolution.

User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jim.bus » 2020-05-14 15:01

SorenR wrote:
2020-05-14 13:54
jim.bus wrote:
2020-05-14 13:31
mattg wrote:
2020-05-14 03:27


Could you just go back and read my last 3 posts? You need 2 extra parameters on the spamd.exe commandline to break the "localhost conundrum". I spend 3 hours investigating this issue last night triggered by your conclusion and my own curiosity. :roll:

If your service launcher for spamd cannot honor parameters on the spamd commandline I suggest you get another!
SorenR, I believe I acknowledged the information from your 3 Posts in my statement which was really directed to mattg responding to his statement he was able to run SpamAssassin on his Ubuntu Web Server. I was explaining I had the problem because I believed since I used Windows, SpamAssassin for Windows was not fully compatible as a Windows Service but pointed out that you had indicated I could override the default listening only to IP 127.0.0.1 bt extending spamd.exe ti listening on all IP Addresses by use of the line command options you had indicated for which I also had found the Options listed on a SpamAssassin webpage (I think you may have pointed me to that as well).

I added additional information which I believed I had read prior about the possibility of other outside connections being able to have access to SpamAssasin which made me have to consider how secure doing that would be and I would need to look at the Options to see if what I remembered of them allowing Authentication of the connection would overcome the security concern. I knew from what you had already posted that I could specify the listening to more IP Addresses than 127.0.0.1.

Especially from what you indicated about the Options allowing all interfaces to listen on Port 783, I need to go back and check if I really need to use NSSM as the Options you refer to being missing from the Command Line might have been my problem in the first place and I may not really need NSSM. The documentation from jimmisaye was a few years old and JAM Software may have updated their version of SpamAssassin. But I still have to consider the possibility I need to Authenticate to make SpamAssassin secure because what I read about access indicated external connections could have access to to email messages. I need to verify that and if so look at the Authentication and SSL options.

So in short, I was aware of your 3 posts and what you were telling me. I needed to consider the possibility of needing Authentication and SSL before rushing ahead and implementing your information. Above all, I don't want to install something that isn't secure if I can help it. And I was appreciative of the information you had supplied as it let me know there was a way around the issue which I knew probably existed but hadn't yet found.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

User avatar
SorenR
Senior user
Senior user
Posts: 6315
Joined: 2006-08-21 15:38
Location: Denmark

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by SorenR » 2020-05-14 15:24

open a command window and enter: nssm edit spamassassin (or whatever you named it)
.
nssm.png
nssm.png (10.65 KiB) Viewed 13734 times
SørenR.

Woke is Marxism advancing through Maoist cultural revolution.

User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jim.bus » 2020-05-14 20:11

SorenR wrote:
2020-05-14 15:24
open a command window and enter: nssm edit spamassassin (or whatever you named it)
.
nssm.png
Thanks much SorenR. I thought it would be something like that. I just needed to go back and find how to do that and you saved me the effort.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

jdperk
New user
New user
Posts: 12
Joined: 2017-01-23 07:57

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jdperk » 2021-09-06 07:41

I am moving to a new server and setting up Spam Assassin and the spamd.exe as a service. I followed the instructions on here and now I am configuring a batch file to stop Spam Assassin service and I cannot get it to work. The results are below. I cannot find the UpdateChannels.txt file which I assume are on Spam Assassin server. I do have the firewall configured for both Spam Assassin and spamd. Running spand.exe directly opens up CMD prompt and freeze after about 5 lines. My server is Windows Server 2019. I am running hmailserver 5.6.7. The Spam Assassin test appear to work within hmailserver. Is something not working as in spamd?

C:\Program Files\JAM Software\SpamAssassin for Windows>net start "Spamassassin (spamd.exe)"
The Spamassassin (spamd.exe) service is starting.
The Spamassassin (spamd.exe) service was started successfully.


C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update.bat

C:\Program Files\JAM Software\SpamAssassin for Windows>net stop "Spamassassin (spamd.exe)"
.
The Spamassassin (spamd.exe) service was stopped successfully.


C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update.exe -v --nogpg --channelfile UpdateChannels.txt
cannot open UpdateChannels.txt for reading: No such file or directory

C:\Program Files\JAM Software\SpamAssassin for Windows>set hr=22

C:\Program Files\JAM Software\SpamAssassin for Windows>if "2" EQU " " set hr=02

C:\Program Files\JAM Software\SpamAssassin for Windows>ren "C:\Program Files (x86)\hMailServer\Logs\SpamAssassin Logs\spamd.log" spamd-2021-05-09-22-31-20.log"
The system cannot find the file specified.

C:\Program Files\JAM Software\SpamAssassin for Windows>net start "Spamassassin (spamd.exe)"
The Spamassassin (spamd.exe) service is starting.
The Spamassassin (spamd.exe) service was started successfully.

User avatar
jimimaseye
Moderator
Moderator
Posts: 10060
Joined: 2011-09-08 17:48

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jimimaseye » 2021-09-06 08:39

jdperk wrote:
2021-09-06 07:41
C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update.exe -v --nogpg --channelfile UpdateChannels.txt
cannot open UpdateChannels.txt for reading: No such file or directory
Have you tried searching for it?

[Entered by mobile. Excuse my spelling.]
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

User avatar
RvdH
Senior user
Senior user
Posts: 3235
Joined: 2008-06-27 14:42
Location: The Netherlands

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by RvdH » 2021-09-06 08:59

jimimaseye wrote:
2021-09-06 08:39
jdperk wrote:
2021-09-06 07:41
C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update.exe -v --nogpg --channelfile UpdateChannels.txt
cannot open UpdateChannels.txt for reading: No such file or directory
Have you tried searching for it?

[Entered by mobile. Excuse my spelling.]
if you only use the official updates, you can simply run it without -channelfile

sa-update.exe -v --nogpg
CIDR to RegEx: d-fault.nl/cidrtoregex
DNS Lookup: d-fault.nl/dnstools
DKIM Generator: d-fault.nl/dkimgenerator
DNSBL Lookup: d-fault.nl/dnsbllookup
GEOIP Lookup: d-fault.nl/geoiplookup

jdperk
New user
New user
Posts: 12
Joined: 2017-01-23 07:57

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jdperk » 2021-09-06 16:27

I am moving to a new server. I am running a MSSQ: database and I restored my hmailserver database from the old server. Hmailserver was able to see the database and restored all of the domains and appears to be working correctly. I downloaded Spamassassin 3.4.4 the UpdateChannels.txt does not exist in the Spam Assassin folder. My old server is still running and the file is in the folder. Is the file suppose to be there or am I suppose to create UpdateChannels.txt file? The batch file on my old server only has the one line "sa-update -v --nogpg --channelfile UpdateChannels.txt" and when run with the service running it appears to work. The batch file code I copied from the instructions here has the line as "sa-update.exe -v --nogpg --channelfile UpdateChannels.txt" note the ".exe" on the sa-update. I don't know if that makes any difference to qualify the file.

My UpdateChannels.txt from my old server has the following:
updates.spamassassin.org
xsaupdate.jam-software.com
sa.zmi.at
sought.rules.yerp.org
spamassassin.heinlein-support.de

I get this error when running the batch file:
C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update -v --nogpg --channelfile UpdateChannels.txt
channel 'sought.rules.yerp.org': no 'mirrors.sought.rules.yerp.org' record found, channel failed
Update failed, exiting with code 4

How is the UpdateChannel.txt create? Does the install of Spam Assassin suppose to create the text file? I did not see instructions directing me to create the text file? Why do I need to stop spamd.exe running as a service to run the "sa-update.exe -v --nogpg --channelfile UpdateChannels.txt" when it appears to work with the service running? Do I need to change the list in the UpdateChannels.txt and if so where do I find a list of sites to enter in the text file?

Below is my batch file executing:
C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update.bat

C:\Program Files\JAM Software\SpamAssassin for Windows>net stop "Spamassassin (spamd.exe)"
.
The Spamassassin (spamd.exe) service was stopped successfully.


C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update -v --nogpg --channelfile UpdateChannels.txt
channel 'sought.rules.yerp.org': no 'mirrors.sought.rules.yerp.org' record found, channel failed
Update failed, exiting with code 4

C:\Program Files\JAM Software\SpamAssassin for Windows>set hr= 7

C:\Program Files\JAM Software\SpamAssassin for Windows>if " " EQU " " set hr=07

C:\Program Files\JAM Software\SpamAssassin for Windows>ren "C:\Program Files (x86)\hMailServer\Logs\SpamAssassin Logs\spamd.log" spamd-2021-06-09-07-05-42.log"

C:\Program Files\JAM Software\SpamAssassin for Windows>net start "Spamassassin (spamd.exe)"
The Spamassassin (spamd.exe) service is starting.
The Spamassassin (spamd.exe) service was started successfully.

My batch file contains:
net stop "Spamassassin (spamd.exe)"
sa-update -v --nogpg --channelfile UpdateChannels.txt
set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
ren "C:\Program Files (x86)\hMailServer\Logs\SpamAssassin Logs\spamd.log" spamd-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-%hr:~-11,2%-%time:~-8,2%-%time:~-5,2%.log"
net start "Spamassassin (spamd.exe)"

I did remove the --round robin from the service parameters. Some insite and instruction of how to properly configure the batch file and spamd service would be helpful. I did schedule to batch file to run every day and it did write a log file without the UpdateChannel.txt file and returned the following:

Sun Sep 5 23:05:46 2021 [2432] info: spamd: server started on IO::Socket::IP [::1]:783, IO::Socket::IP [127.0.0.1]:783 (running version 3.4.4)
Sun Sep 5 23:05:46 2021 [2432] info: spamd: server pid: 2432
Sun Sep 5 23:05:46 2021 [2432] info: spamd: server successfully spawned child process, pid -8044
Sun Sep 5 23:05:47 2021 [2432] info: spamd: server successfully spawned child process, pid -96
Sun Sep 5 23:05:47 2021 [2432] info: prefork: child states: IS
Sun Sep 5 23:05:47 2021 [2432] info: prefork: child states: II
Mon Sep 6 02:13:02 2021 [2432] info: spamd: server killed by SIGINT, shutting down

With the UpdateChannel.txt file manually run the batch created the following:

Mon Sep 6 02:13:05 2021 [752] info: spamd: server started on IO::Socket::IP [::1]:783, IO::Socket::IP [127.0.0.1]:783 (running version 3.4.4)
Mon Sep 6 02:13:05 2021 [752] info: spamd: server pid: 752
Mon Sep 6 02:13:06 2021 [752] info: spamd: server successfully spawned child process, pid -7400
Mon Sep 6 02:13:06 2021 [752] info: spamd: server successfully spawned child process, pid -636
Mon Sep 6 02:13:06 2021 [752] info: prefork: child states: II
Mon Sep 6 06:39:06 2021 [-7400] info: spamd: connection from s208-109-39-188.secureserver.net [127.0.0.1]:63489 to port 783, fd 7
Mon Sep 6 06:39:06 2021 [-7400] info: spamd: processing message <otqrInY3QViD76OfN_--HA@ismtpd0184p1mdw1.sendgrid.net> for (unknown):0
Mon Sep 6 06:39:07 2021 [-7400] info: spamd: clean message (0.0/5.0) for (unknown):0 in 0.8 seconds, 6193 bytes.
Mon Sep 6 06:39:07 2021 [-7400] info: spamd: result: . 0 - DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HTML_MESSAGE,MIME_HTML_ONLY,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_FILL_THIS_FORM_SHORT,UNPARSEABLE_RELAY,URIBL_BLOCKED scantime=0.8,size=6193,user=(unknown),uid=0,required_score=5.0,rhost=s208-109-39-188.secureserver.net,raddr=127.0.0.1,rport=63489,mid=<otqrInY3QViD76OfN_--HA@ismtpd0184p1mdw1.sendgrid.net>,autolearn=ham autolearn_force=no
Mon Sep 6 06:39:07 2021 [752] info: prefork: child states: II
Mon Sep 6 07:05:39 2021 [752] info: spamd: server killed by SIGINT, shutting down

Did the first one without the UpdateChannels.txt file actually work? I am trying to give you as much information as possible. I appreciate the help. I want to configure this and forget this for awhile.

User avatar
RvdH
Senior user
Senior user
Posts: 3235
Joined: 2008-06-27 14:42
Location: The Netherlands

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by RvdH » 2021-09-06 18:29

Both seem fine to me, it simply looks like you didn't receive any mail yesterday between Sun Sep 5 23:05:46 2021 and Mon Sep 6 02:13:02 2021

FYI, i am using sa-update.exe -v --nogpg (without channelfile) for ages without problems

How is the UpdateChannel.txt create? Does the install of Spam Assassin suppose to create the text file?
3.4.2 included UpdateChannel.txt, 3.4.4 did not (but you simple can use 3.4.2 UpdateChannel.txt if you like to)

simply comment sought.rules.yerp.org (prepend #) that one is no longer online/active


For the sake of readability, post a summary of your questions at the bottom so we don't have to read/browse the whole post for question marks :lol:
CIDR to RegEx: d-fault.nl/cidrtoregex
DNS Lookup: d-fault.nl/dnstools
DKIM Generator: d-fault.nl/dkimgenerator
DNSBL Lookup: d-fault.nl/dnsbllookup
GEOIP Lookup: d-fault.nl/geoiplookup

jdperk
New user
New user
Posts: 12
Joined: 2017-01-23 07:57

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jdperk » 2021-09-06 22:19

I ended up uninstalling hmailserver 5.6.7 then restoring the database from the old server. I reinstalled hmailserver 5.6.7 and pointed it to the MSSQL database. Everything looks to be working.

I see ClamAV check.
I see Spam Score.
I see emails going through so far.

In hmailserver Anti-virus on the ClamAV tab pressing the Test button error out. However, I do see an error trapped with the anti virus on the server. So far at this point that is the only thing that appears to not be working which is no big deal.

Questions:
- Why stop spamd service in the batch file before running the sa-update?
- I ran the sa-update.exe and it did not an update because there were no new updates. It failed to create a log file from the batch file. I assume this is normal since it did nothing. Is there some code I can add to the batch file to skip the ren (rename) of the spamd.log file because it does not exist? Maybe this is no big deal to fail on not finding the file?
- Are there any other sites I can add to the updatechannes.txt files?
- Is everyone not using the UpdateChannel.txt file?

User avatar
RvdH
Senior user
Senior user
Posts: 3235
Joined: 2008-06-27 14:42
Location: The Netherlands

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by RvdH » 2021-09-06 22:27

jdperk wrote:
2021-09-06 22:19

Questions:
- Why stop spamd service in the batch file before running the sa-update?
- I ran the sa-update.exe and it did not an update because there were no new updates. It failed to create a log file from the batch file. I assume this is normal since it did nothing. Is there some code I can add to the batch file to skip the ren (rename) of the spamd.log file because it does not exist? Maybe this is no big deal to fail on not finding the file?
- Are there any other sites I can add to the updatechannes.txt files?
- Is everyone not using the UpdateChannel.txt file?
Anwsers:
- i think (not using batch myself) because spamd must be restarted to load installed updates
- as said, not using batch myself, try it :mrgreen:
- sure
- that is a stupid question

Exclude hmailserver's /Data /Temp folders from realtime virusscanner on the system, after that clamav should work normally (this is clearly documented!)
CIDR to RegEx: d-fault.nl/cidrtoregex
DNS Lookup: d-fault.nl/dnstools
DKIM Generator: d-fault.nl/dkimgenerator
DNSBL Lookup: d-fault.nl/dnsbllookup
GEOIP Lookup: d-fault.nl/geoiplookup

User avatar
jim.bus
Senior user
Senior user
Posts: 1571
Joined: 2011-05-28 11:49
Location: US

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jim.bus » 2021-09-07 03:42

jdperk wrote:
2021-09-06 07:41
I am moving to a new server and setting up Spam Assassin and the spamd.exe as a service. I followed the instructions on here and now I am configuring a batch file to stop Spam Assassin service and I cannot get it to work. The results are below. I cannot find the UpdateChannels.txt file which I assume are on Spam Assassin server. I do have the firewall configured for both Spam Assassin and spamd. Running spand.exe directly opens up CMD prompt and freeze after about 5 lines. My server is Windows Server 2019. I am running hmailserver 5.6.7. The Spam Assassin test appear to work within hmailserver. Is something not working as in spamd?

C:\Program Files\JAM Software\SpamAssassin for Windows>net start "Spamassassin (spamd.exe)"
The Spamassassin (spamd.exe) service is starting.
The Spamassassin (spamd.exe) service was started successfully.


C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update.bat

C:\Program Files\JAM Software\SpamAssassin for Windows>net stop "Spamassassin (spamd.exe)"
.
The Spamassassin (spamd.exe) service was stopped successfully.


C:\Program Files\JAM Software\SpamAssassin for Windows>sa-update.exe -v --nogpg --channelfile UpdateChannels.txt
cannot open UpdateChannels.txt for reading: No such file or directory

C:\Program Files\JAM Software\SpamAssassin for Windows>set hr=22

C:\Program Files\JAM Software\SpamAssassin for Windows>if "2" EQU " " set hr=02

C:\Program Files\JAM Software\SpamAssassin for Windows>ren "C:\Program Files (x86)\hMailServer\Logs\SpamAssassin Logs\spamd.log" spamd-2021-05-09-22-31-20.log"
The system cannot find the file specified.

C:\Program Files\JAM Software\SpamAssassin for Windows>net start "Spamassassin (spamd.exe)"
The Spamassassin (spamd.exe) service is starting.
The Spamassassin (spamd.exe) service was started successfully.
Can you please start your own thread on your Topic. I am the Original Poster and your Topic doesn't seem to be related to my Topic and I keep getting Notifications of responses to your new Topic and generally I have no comment to make about them.

Thank you.
If you think you understand quantum mechanics, you don't understand quantum mechanics.

jdperk
New user
New user
Posts: 12
Joined: 2017-01-23 07:57

Re: SpamAssassin SA-Update.exe In Task Scheduler Reports Task Successful But SA-Update Gets Nonzero Return Code

Post by jdperk » 2021-09-08 03:29


Can you please start your own thread on your Topic. I am the Original Poster and your Topic doesn't seem to be related to my Topic and I keep getting Notifications of responses to your new Topic and generally I have no comment to make about them.

Thank you.
Please go ahead and delete my 3 post on this thread. I don't have the rights to delete my post on this thread. Sorry I didn't intend to hijack your thread. I am not a seasoned forum user and don't post a lot on forums. In the future I will start my own problem thread if I post.

Thank you for letting me know I was not to add to your thread.

Post Reply