in reply to Re: Postgresql output to file
in thread Postgresql output to file

You are correct. And I can run that with the -o /home/user/date.txt Works well if I run it manually. But, I need it to run as a cron job every night at 23:59, and add the date as the filename. ie...09012024.txt 09022024.txt 09032024.txt

Replies are listed 'Best First'.
Re^3: Postgresql output to file
by afoken (Chancellor) on Sep 05, 2024 at 16:29 UTC
    I need it to run as a cron job every night at 23:59, and add the date as the filename.

    That's easy with a shell script. Replace -o /home/user/date.txt with -o "/home/user/$(date '+%m%d%Y').txt". Replace the format string passed to the date command with '+%Y%m%d' to get easily sortable file names instead of that M/D/Y mess.

    (Yes, I prefer using perl over shell, but sometimes, the shell is just more efficient.)

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)