Clear PostgreSQL logs in AWS Ubuntu Server
That is a bash problem. The redirection (&gt;) is not part of the command executed as root, but as your current user.
Use this workaround:
sudo sh -c &quot;&gt; /var/log/postgresql/postgresql-11-main.log&quot;