I am running
php bin/magento setup:upgrade
command after migration from one aws instance to another Instance and It is hanged and stuck not moving forward??
You can check by run below command:
strace -s 99 bin/magento setup:upgrade
More about strace
Also, check your MySQL has not run any related process, you found then kill it. (Not KILL ALL, only related Processes need to kill)
SHOW FULL PROCESSLIST kill ProcessID
In My case customer_visitor table cause an error and stops the command. After debugging more in DB, there are many entries, so he takes more time to run and stop the upgrade command execution.
I remove all entries from customer_visitor table and then It's working.
TRUNCATE TABLE customer_visitor;