And again what @JimmyKater already asked: what’s the exact place you try running it and whats the exact command?
This means the context (which folder?) you try to run occ in? Can you post the command you are trying?
Like if you move to the right folder (/var/www/nextcloud using cd) is the following working?
sudo -u www-data php occ -h
Anyway: You might be triggering the Linux out-of-memory (OOM) killer. Check
dmesg for messages about it. It says which process was killed when this happens. How many RAM does your server have for use?