 ls -la /opt/ids/.env
-rw-r--r--. 1 ids ids 351 Nov 17 17:23 /opt/ids/.env
[root@ids python_ml]# cat /opt/ids/.env | grep PGPASSWORD
PGPASSWORD=TestPassword123
[root@ids python_ml]# sudo chmod 640 /opt/ids/.env
[root@ids python_ml]# sudo chown ids:ids /opt/ids/.env
[root@ids python_ml]# sudo -u ids bash -c 'source /opt/ids/.env && echo "Password letta: $PGPASSWORD"'
Password letta: TestPassword123
[root@ids python_ml]# sudo -u ids bash -c 'export PGPASSWORD="TestPassword123" && psql -h ::1 -U ids_user -d ids_database -c "SELECT 1;"'
 ?column?
----------
        1
(1 row)

[root@ids python_ml]# pkill -f syslog_parser
[root@ids python_ml]# sudo -u ids PGPASSWORD="TestPassword123" nohup python3.11 syslog_parser.py > /var/log/ids/syslog_parser.log 2>&1 &
[1] 59430
[root@ids python_ml]# sleep 2
[1]+  Done                    sudo -u ids PGPASSWORD="TestPassword123" nohup python3.11 syslog_parser.py > /var/log/ids/syslog_parser.log 2>&1
[root@ids python_ml]# tail -20 /var/log/ids/syslog_parser.log
nohup: ignoring input
=== SYSLOG PARSER PER ROUTER MIKROTIK ===
Pressione Ctrl+C per interrompere

[INFO] Connesso a PostgreSQL
[INFO] Processando /var/log/mikrotik/raw.log (follow=True)
[ERROR] Errore processamento file: [Errno 13] Permission denied: '/var/log/mikrotik/raw.log'
[INFO] Totale: 0 righe processate, 0 log salvati
[INFO] Disconnesso da PostgreSQL
[root@ids python_ml]# sudo -u ids nohup python3.11 syslog_parser.py > /var/log/ids/syslog_parser.log 2>&1 &
[1] 59438
[root@ids python_ml]# tail -20 /var/log/ids/syslog_parser.log
nohup: ignoring input
=== SYSLOG PARSER PER ROUTER MIKROTIK ===
Pressione Ctrl+C per interrompere

[ERROR] Connessione database fallita: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "ids_user"

[INFO] Disconnesso da PostgreSQL
Traceback (most recent call last):
  File "/opt/ids/python_ml/syslog_parser.py", line 215, in <module>
    main()
  File "/opt/ids/python_ml/syslog_parser.py", line 203, in main
    parser.connect_db()
  File "/opt/ids/python_ml/syslog_parser.py", line 48, in connect_db
    self.conn = psycopg2.connect(**self.db_config)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ids/.local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "ids_user"

[1]+  Exit 1                  sudo -u ids nohup python3.11 syslog_parser.py > /var/log/ids/syslog_parser.log 2>&1