Using @startup or @reboot in a schedule


#1 Tony Curoso

Hello. I am using nxlog community edition 3.2.2329_ubuntu20_amd64.deb on ubuntu 20.04.6. I am trying to rotate and purge logs on a daily basis. This is a dev environment that shuts down from 6pm to 7am daily. I tried using a Schedule block with a directive of When to @startup but that throws an error when starting nxlog. Also tried @reboot and got the same error. 

Here are snippets of the  nxlog.conf with @reboot. 

<Output fileout1>   Module om_file   File "/var/log/nxlog/syslog.txt"   Exec if $Message =~ /error/ $SeverityValue = syslog_severity_value("error");   Exec to_syslog_bsd();<Schedule>        # This can likewise be used for `@weekly` or `@monthly` time periods.         When @reboot

        # The following crontab-style is the same as `@daily` above.        # When "0 0 * * *"

         # The `Every` directive could also be used in this case.         #Every @startup

        Exec    rotate_to(file_name() + strftime(now(), '_%Y-%m-%d'));    </Schedule></Output>…

<Output fileout2>   Module om_file   File "/var/log/nxlog/logmsg2.txt"</Output><Extension fileop>Module xm_fileop<Schedule> When @reboot # Delete logs older than 14 days (24x60x60x30)        Exec    file_remove('/var/log/nxlog/*.txt*', now() - 1209600);</Schedule></Extension> 

Here is the output from console when I try to start nxlog

ubuntu@ip-172-31-17-93:~$ sudo systemctl restart nxlogJob for nxlog.service failed because the control process exited with error code.See "systemctl status nxlog.service" and "journalctl -xe" for details.ubuntu@ip-172-31-17-93:~$ sudo systemctl status nxlog.service● nxlog.service - NXLog daemon    Loaded: loaded (/lib/systemd/system/nxlog.service; enabled; vendor preset: enabled)    Active: failed (Result: exit-code) since Fri 2025-02-28 09:49:47 PST; 29s ago   Process: 2821 ExecStartPre=/usr/bin/nxlog -v (code=exited, status=1/FAILURE)

Feb 28 09:49:47 ip-172-31-17-93 systemd[1]: Starting NXLog daemon...Feb 28 09:49:47 ip-172-31-17-93 nxlog[2821]: 2025-02-28 09:49:47 ERROR couldn't parse value for directive 'When': @reboot not supported at /etc/nxlog/nxlog.conf:43Feb 28 09:49:47 ip-172-31-17-93 systemd[1]: nxlog.service: Control process exited, code=exited, status=1/FAILUREFeb 28 09:49:47 ip-172-31-17-93 systemd[1]: nxlog.service: Failed with result 'exit-code'.Feb 28 09:49:47 ip-172-31-17-93 systemd[1]: Failed to start NXLog daemon. 

Seems like it does not like the When directive, but not sure why since it is in the documentation. nxlog starts fine if I use @daily, but since the system is shut down during the day change, the operations are not performed. 

Thanks!