After a day of research, the problem has been solved by modifying the bin/gerrit.sh startup script. In this shell script, the su command is used to switch users and execute the startup command, but the addition of the - parameter causes the shell to enter the login mode.

The solution is to delete the - parameter, as shown in the figure:

Then use "./gerrit.sh restart" to restart gerrit