Clear PostgreSQL logs in AWS Ubuntu Server I am trying to clear the logs of an postgresql under /var/log/postgresql/ but I am getting error message as below:
 /var/log/postgresql$ sudo &gt; postgresql-11-main.log
 -bash: postgresql-11-main.log: Permission denied

Below is folder files structure:
 /var/log/postgresql$ ls -la
 total 1097296
 drwxrwxr-t  2 root     postgres       4096 Apr 25 06:56 .
 drwxrwxr-x 12 root     syslog         4096 Apr 28 06:35 ..
 -rw-r-----  1 postgres adm      1107919237 Apr 29 06:33 postgresql-11-main.log
 -rw-r-----  1 postgres adm        14480619 Apr 25 06:56 postgresql-11-main.log.1
 -rw-r-----  1 postgres adm         1199751 Apr 18 06:49 postgresql-11-main.log.2.gz

Also, is it okay to clear the logs of an PostgreSQL? will it harm any existing database or work flow?
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;