The error message you note suggests that it can't find the "command.php" file. My guess is that you weren't in the web root. Also, FYI, it's best to run those commands as the webserver user. You can do that like this:
runuser -l www-data -s /bin/bash -c "cd /var/www/espocrm && php command.php upgrade -y"
Hopefully that should do the job. Please post back if you hit any further issues.
More information about text formats
Did you run that in the web root?
The error message you note suggests that it can't find the "command.php" file. My guess is that you weren't in the web root. Also, FYI, it's best to run those commands as the webserver user. You can do that like this:
Hopefully that should do the job. Please post back if you hit any further issues.