I manage a very busy Rocky Linux test-server. For one staging environment, cron is already running five or six maintenance scripts every minute. But when the tests run, the system has to do a lot of additional permissions fixes and filesystem adjustments. I’ve started seeing in the logs the following error message:
pam_systemd(sudo:session): Failed to create session: Maximum number of sessions (8192) reached, refusing further sessions
Now, there is a known older problem with systemd and dbus, that comes up when you search for this error message. I couldn’t find any concrete actions I could take to fix the issue. The other major search results are RedHat pages behind their subscription wall, and, at this point I’m apparently too dumb and out of date to even be able to figure out how to pay for a RedHat subscription.
I think I’ve found at least a temporary solution, however. In
/etc/systemd/logind.conf there is the
SessionsMax field where you can override the default. I doubled it to 16384, then ran
systemctl restart systemd-logind
I’ll have to see if that’s a viable long-term fix rather than just treating the symptoms of a bigger issue.