Mattermost create user command exited

I tried executing mattermost user create command before starting the mattermost server and it exits after creating the server

Hi, @tsadkan

Can I confirm that you are get something that looks like this on your end or something else? I am trying to understand what you mean by the “it exits after creating the server” part now:

ahmaddanial@mattermost:/opt/mattermost$ bin/mattermost user create --email ahmad.danial@example.com --username danial.example --password Password123!
2020-06-11T03:39:18.125Z	info	utils/i18n.go:83	Loaded system translations	{"for locale": "en", "from locale": "/opt/mattermost/i18n/en.json"}
2020-06-11 03:39:18.127381447 +0000 UTC m=+0.214806723 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.127.log: permission denied
2020-06-11T03:39:18.127Z	info	app/server_app_adapters.go:58	Server is initializing...
2020-06-11 03:39:18.128905454 +0000 UTC m=+0.216330682 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.128.log: permission denied
2020-06-11T03:39:18.129Z	debug	app/enterprise.go:147	Loading original SAML library
2020-06-11 03:39:18.130998663 +0000 UTC m=+0.218423901 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.130.log: permission denied
2020-06-11T03:39:18.131Z	debug	utils/html.go:30	Parsing server templates	{"templates_directory": "/opt/mattermost/templates"}
2020-06-11 03:39:18.132199634 +0000 UTC m=+0.219624862 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.132.log: permission denied
2020-06-11T03:39:18.133Z	info	sqlstore/supplier.go:224	Pinging SQL	{"database": "master"}
2020-06-11 03:39:18.134739828 +0000 UTC m=+0.222165073 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.134.log: permission denied
2020-06-11T03:39:18.174Z	debug	sqlstore/preference_store.go:41	Deleting any unused pre-release features
2020-06-11 03:39:18.174932303 +0000 UTC m=+0.262357543 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.174.log: permission denied
2020-06-11T03:39:18.206Z	error	app/server_app_adapters.go:139	Mail server connection test is failed: SendEmailNotifications is not true
2020-06-11 03:39:18.214223532 +0000 UTC m=+0.301648765 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.214.log: permission denied
2020-06-11T03:39:18.222Z	error	app/server_app_adapters.go:151	Problem with file storage settings	{"error": "TestFileConnection: Don't have permissions to write to local path specified or other error., WriteFile: Encountered an error writing to local server storage., open data/testfile: permission denied"}
2020-06-11 03:39:18.224215103 +0000 UTC m=+0.311640332 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.224.log: permission denied
2020-06-11T03:39:18.226Z	info	app/license.go:43	License key valid unlocking enterprise features.
2020-06-11 03:39:18.22737401 +0000 UTC m=+0.314799258 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.227.log: permission denied
2020-06-11T03:39:18.231Z	info	mlog/log.go:167	Starting up plugins
2020-06-11 03:39:18.232277037 +0000 UTC m=+0.319702267 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.232.log: permission denied
2020-06-11T03:39:18.232Z	info	app/plugin.go:202	Syncing plugins from the file store
2020-06-11 03:39:18.233596415 +0000 UTC m=+0.321021654 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.233.log: permission denied
2020-06-11T03:39:18.233Z	error	app/plugin.go:173	Failed to sync plugins from the file store	{"error": "SyncPlugins: Error reading local plugins folder., lstat ./plugins/com.mattermost.nps: permission denied"}
2020-06-11 03:39:18.235225406 +0000 UTC m=+0.322650647 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.235.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-antivirus-v0.1.2-linux-amd64.tar.gz"}
2020-06-11 03:39:18.236240251 +0000 UTC m=+0.323665502 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.236.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-custom-attributes-v1.0.2-linux-amd64.tar.gz"}
2020-06-11 03:39:18.259328207 +0000 UTC m=+0.346753441 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.259.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-gitlab-v1.0.1-linux-amd64.tar.gz"}
2020-06-11 03:39:18.308977003 +0000 UTC m=+0.396402264 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.308.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-jira-v2.3.2-linux-amd64.tar.gz"}
2020-06-11 03:39:18.388918086 +0000 UTC m=+0.476343347 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.388.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-autolink-v1.1.2-linux-amd64.tar.gz"}
2020-06-11 03:39:18.469122525 +0000 UTC m=+0.556547766 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.469.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-aws-SNS-v1.0.2-linux-amd64.tar.gz"}
2020-06-11 03:39:18.532128191 +0000 UTC m=+0.619553432 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.532.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-github-v0.11.0-linux-amd64.tar.gz"}
2020-06-11 03:39:18.626307389 +0000 UTC m=+0.713732627 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.626.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-jenkins-v1.0.0-linux-amd64.tar.gz"}
2020-06-11 03:39:18.785367144 +0000 UTC m=+0.872792414 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.783.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-nps-v1.0.4-linux-amd64.tar.gz"}
2020-06-11 03:39:18.930169493 +0000 UTC m=+1.017594737 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-18.930.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-welcomebot-v1.1.1-linux-amd64.tar.gz"}
2020-06-11 03:39:19.08890807 +0000 UTC m=+1.176333306 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-19.088.log: permission denied
2020-06-11T03:39:18.235Z	debug	app/plugin.go:794	Processing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-zoom-v1.3.0-linux-amd64.tar.gz"}
2020-06-11 03:39:19.251149437 +0000 UTC m=+1.338574677 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-19.251.log: permission denied
2020-06-11T03:39:20.316Z	debug	app/plugin.go:824	Installing prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-nps-v1.0.4-linux-amd64.tar.gz"}
2020-06-11 03:39:20.316987237 +0000 UTC m=+2.404412480 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.316.log: permission denied
2020-06-11T03:39:20.319Z	error	app/plugin.go:774	Failed to install prepackaged plugin	{"path": "/opt/mattermost/prepackaged_plugins/mattermost-plugin-nps-v1.0.4-linux-amd64.tar.gz", "error": "Failed to install extracted prepackaged plugin /opt/mattermost/prepackaged_plugins/mattermost-plugin-nps-v1.0.4-linux-amd64.tar.gz: installExtractedPlugin: Unable to install plugin., lstat ./plugins/com.mattermost.nps: permission denied", "errorVerbose": "installExtractedPlugin: Unable to install plugin., lstat ./plugins/com.mattermost.nps: permission denied\nFailed to install extracted prepackaged plugin /opt/mattermost/prepackaged_plugins/mattermost-plugin-nps-v1.0.4-linux-amd64.tar.gz\ngithub.com/mattermost/mattermost-server/v5/app.(*App).processPrepackagedPlugin\n\tgithub.com/mattermost/mattermost-server/v5@/app/plugin.go:826\ngithub.com/mattermost/mattermost-server/v5/app.(*App).processPrepackagedPlugins.func2\n\tgithub.com/mattermost/mattermost-server/v5@/app/plugin.go:772\nruntime.goexit\n\truntime/asm_amd64.s:1357"}
2020-06-11 03:39:20.324803273 +0000 UTC m=+2.412228503 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.324.log: permission denied
2020-06-11T03:39:20.378Z	error	mlog/log.go:175	Unable to get available plugins	{"error": "lstat ./plugins/com.mattermost.nps: permission denied"}
2020-06-11 03:39:20.380198934 +0000 UTC m=+2.467624195 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.380.log: permission denied
2020-06-11T03:39:20.380Z	debug	plugin/environment.go:506	Enabling plugin health check job	{"interval_s": 30}
2020-06-11 03:39:20.381676163 +0000 UTC m=+2.469101391 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.381.log: permission denied
2020-06-11T03:39:20.381Z	info	app/server.go:255	Current version is 5.23.0 (5.23.0/Thu May 14 12:18:07 UTC 2020/ed1576d007a09b07574b18784b9eabb3d8c9db53/9d6d6b0a601330640d7cfe0e64be5ea6a41436d4)	{"current_version": "5.23.0", "build_number": "5.23.0", "build_date": "Thu May 14 12:18:07 UTC 2020", "build_hash": "ed1576d007a09b07574b18784b9eabb3d8c9db53", "build_hash_enterprise": "9d6d6b0a601330640d7cfe0e64be5ea6a41436d4"}
2020-06-11 03:39:20.383182954 +0000 UTC m=+2.470608182 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.383.log: permission denied
2020-06-11T03:39:20.383Z	info	app/server.go:264	Enterprise Build	{"enterprise_build": true}
2020-06-11 03:39:20.383236098 +0000 UTC m=+2.470661326 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.383.log: permission denied
2020-06-11T03:39:20.383Z	info	app/server.go:270	Printing current working	{"directory": "/opt/mattermost"}
2020-06-11 03:39:20.383277512 +0000 UTC m=+2.470702740 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.383.log: permission denied
2020-06-11T03:39:20.382Z	debug	plugin/health_check.go:31	Plugin health check job starting.
2020-06-11 03:39:20.383547609 +0000 UTC m=+2.470972837 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.383.log: permission denied
2020-06-11T03:39:20.383Z	info	app/server.go:271	Loaded config	{"source": "file:///opt/mattermost/config/config.json"}
2020-06-11 03:39:20.383833873 +0000 UTC m=+2.471259101 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.383.log: permission denied
2020-06-11T03:39:20.426Z	info	sqlstore/post_store.go:1524	Post.Message has size restrictions	{"max_characters": 16383, "max_bytes": 65535}
2020-06-11 03:39:20.428376102 +0000 UTC m=+2.515801324 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.428.log: permission denied
2020-06-11T03:39:20.429Z	error	mlog/log.go:175	Unable to get available plugins	{"error": "lstat ./plugins/com.mattermost.nps: permission denied"}
2020-06-11 03:39:20.431004901 +0000 UTC m=+2.518430136 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.430.log: permission denied
2020-06-11T03:39:20.431Z	error	mlog/log.go:175	Unable to get available plugins	{"error": "lstat ./plugins/com.mattermost.nps: permission denied"}
2020-06-11 03:39:20.432041873 +0000 UTC m=+2.519467109 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.432.log: permission denied
2020-06-11T03:39:20.444Z	debug	utils/html.go:30	Parsing server templates	{"templates_directory": "/opt/mattermost/templates"}
2020-06-11 03:39:20.444144819 +0000 UTC m=+2.531570048 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.444.log: permission denied
2020-06-11T03:39:20.445Z	debug	jobs/schedulers.go:30	Initialising schedulers.
2020-06-11 03:39:20.445207684 +0000 UTC m=+2.532632918 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.445.log: permission denied
2020-06-11T03:39:20.446Z	info	app/license.go:43	License key valid unlocking enterprise features.
2020-06-11 03:39:20.447203733 +0000 UTC m=+2.534628976 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.447.log: permission denied
2020-06-11T03:39:20.447Z	error	mlog/log.go:175	Unable to get available plugins	{"error": "lstat ./plugins/com.mattermost.nps: permission denied"}
2020-06-11 03:39:20.447722332 +0000 UTC m=+2.535147569 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.447.log: permission denied
id: wqfn54nc9fyr8dbu4c14ho4o5c
username: danial.example
nickname:
position:
first_name:
last_name:
email: ahmad.danial@example.com
auth_service:
2020-06-11T03:39:20.546Z	info	app/server.go:402	Stopping Server...
2020-06-11 03:39:20.546459725 +0000 UTC m=+2.633884953 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.546.log: permission denied
2020-06-11T03:39:20.546Z	info	app/web_hub.go:130	stopping websocket hub connections
2020-06-11 03:39:20.546495185 +0000 UTC m=+2.633920413 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.546.log: permission denied
2020-06-11T03:39:20.546Z	warn	app/web_hub.go:135	We appear to have already sent the stop checking for deadlocks command
2020-06-11 03:39:20.546517564 +0000 UTC m=+2.633942799 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.546.log: permission denied
2020-06-11T03:39:20.546Z	info	app/plugin.go:279	Shutting down plugins
2020-06-11 03:39:20.546744181 +0000 UTC m=+2.634169409 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.546.log: permission denied
2020-06-11T03:39:20.547Z	info	app/server.go:453	Server stopped
2020-06-11 03:39:20.549320418 +0000 UTC m=+2.636745652 write error: can't rename log file: rename /opt/mattermost/logs/mattermost.log /opt/mattermost/logs/mattermost-2020-06-11T03-39-20.549.log: permission denied

From the UI, you can see that the user gets created.

Did you check from the UI if the user gets successfully created or are there errors on the log?

@ahmaddanial, thank you for your response.
I was using mattermost via docker and I wanted to create the admin user before starting the server. here is my script

exec mattermost user create --email test@test.com --username test --password ComplexP@ssword1234 && \ exec mattermost

but the first command inserts the user to db and exits and the server is not started at the port. Can you please help me with the idea on create an admin user before at the start.