Set custom postgres pid and log file - postgresql

I tried to set up new configs for my postgres, but for some reason I can't do it correctly.
First of my trying is to move .pid file to some other location, I can rename the file in postgres.conf but I can't set it to directory I need.
Same situation is with .log file.
Why when I tried to set pid file using external_pid_file = '/home/vagrant/shared/pids/postgres.pid' file isn't created? Or when I tried to set log file to /home/vagrant/shared/logs folder I have the same issue.
My config file:
https://pastebin.com/ud6HSJrn

Related

Postgres initdb: How to set logging_collector=on in the generated postgressql.conf file

The default postgresql.conf file created using initdb contains the following line
#logging_collector = off # Enable capturing of stderr and csvlog
Is there anyway to force initdb itself to generate a file with
logging_collector = on
rather than set options on pg-ctl or edit the generated file.
I keep all the changes in a separate file named custom.conf
Then after initdb ran, I copy the file to the data directory and append an include directive to postgresql.conf:
cp /path/to/dir/custom.conf $PGDATA
echo include = 'custom.conf' >> $PGDATA/postgresql.conf
These steps are easily scriptable, so no manual intervention required.
Alternatively you can skip the copy step and include the config file directly from the central directory. Or you could use include_dir to include the whole directory where your custom config file is stored.
This has the added benefit (in my opinion) that I have all customizations in a single file. I don't need to go through postgresql.conf to find settings that are changed from the default.
No, there is no way to do it like that.
But you can modify the file postgresql.conf.sample in the “share” directory of the PostgreSQL installation, which is used as the blueprint for postgresql.conf during initdb.

rsyslog log file with wildcards

configure rsyslog to monitor direcory files when log file name changed
I have a service that creates a new log file each hour with the hour in the file name i.e: ecs-agent.log.2019-03-26-08
Each time the file changed rsyslog doesnt recognize the change.
the following settings in the conf file will not work:
$InputFileName /var/log/ecs/ecs-agent.log.*
$InputFileStateFile stat-ecs-agent.log.*
Since there is only one log file in the folder active each time - anyway to configure rsyslog to monitor the folder?

How to overwrite existing files with ncftpget?

When getting a remote ftp file that exists in the local destination
ncftpget says that
local file appears to be the same as the remote file, download is not necessary.
What does appears mean? How does ncftpget check if this is the same file?
It seems that it compares time and size of the file. But does it compare content or at least checksum?
Is there a way to force to overwrite the existing file. Of course other than remove it first.

How to get the current config filename

I want to be able to output the currently loaded config filename, is this possible?
I want to basically write out a log entry with the config filename so I know which config file loaded just to verify things.

Create a batch file to copy and rename file

I need to write a batch file that copies a file to a new folder and renames it.
At the moment, my batch file consists of only this command:
COPY ABC.PDF \\Documents
As you can see, it only copies the file ABC.pdf to the network folder Documents.
However I need to change this so it renames the file ABCxxx.pdf, where xxx is a text variable that I would like to set somewhere in the batch file.
For example, if xxx = _Draft, then file would be renamed ABC_Draft.pdf after it is copied.
Make a bat file with the following in it:
copy /y C:\temp\log1k.txt C:\temp\log1k_copied.txt
However, I think there are issues if there are spaces in your directory names. Notice this was copied to the same directory, but that doesn't matter. If you want to see how it runs, make another bat file that calls the first and outputs to a log:
C:\temp\test.bat > C:\temp\test.log
(assuming the first bat file was called test.bat and was located in that directory)
type C:\temp\test.bat>C:\temp\test.log