I have a shell script containing multiple PSQL queries for which I want the output to be redirected to a text file.
When executing the script, queries outputs are directed to textfile.txt, however when script was set in cron, textfile.txt is not being updated.
Does anyone have a different way how I can output query results to a text file.
Moderator's Comments:
Please use CODE tags as required by forum rules!
Last edited by RudiC; 03-20-2017 at 08:15 AM..
Reason: Added CODE tags.
Hi,
I new to Unix and scripting. Following is my requirement. Can someone tell me whether its possible or not. Also please let me know how to proceed further if this is possible.
List of queries are stored in a file. For example, I have to run a query like this:
Select * from &XYZ where... (0 Replies)
Hi guys,
i know how to run a single query using mysql embedded in a shell script as follows:
`mysql -umyuser -pmypass --host myhost database<<SQL
${query};
quit
SQL`
However, how would i be able to run several queries within the same connection?
The reason for this is i am creating... (3 Replies)
Hi folks,
I've been using grep -f file1 file2 to get lines that match a file1 line from file2. I'm now interested in getting the lines from file1 where there was no match in file2.
I believe the -v option will give me unmatched lines from file2, but I'm looking for unmatched lines from... (3 Replies)
Hi Everyone,
When i finish running
# echo `psql -t -U root databaseA -c "select a, b from book"`;
i get the output
107275 | 14 107301 | 2 107446 | 6 107820 | 77 107929 | 101
Would like to have the result like:
107275 | 14
107301 | 2
107446 | 6
107820 | 77
107929 | 101 (7 Replies)
Hello everyone,
It's my first week using unix and shell scripting. I tried creating a script that has a function that execute SQL query. my script looks something like this:
----------------------------------------------------
#!/bin/sh
tableName="myTable"
secondTable="secondTable"... (2 Replies)
I need to connect a databas eusing sqlplus and i need to store the results of each query in separate file.
is it possible to achieve this usng single sqlplus?
i dont want to connect each time for each query.
thanks (3 Replies)
Hi,
I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command.
Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns.
Xargs -I {} grep... (3 Replies)
Hi All,
I have a file queries.txt as follows :
SELECT COLUMN1 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN1 FROM SCDEMA2.TABLE2;
SELECT COLUMN2 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN2 FROM SCDEMA2.TABLE2;
SELECT COLUMN3 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN3 FROM SCDEMA2.TABLE2;
SELECT... (2 Replies)
Hello
Just edited the entry to make it easier to understand what i want
How can i achieve this: GOAL:
read 2 field from a table with PSQL
result of this PSQL command is this
INSTALLEDLANG=$(su - postgres -c "psql -A -t -q -c -d ${DBNAME} -t -c 'SELECT code, iso_code from res_lang'")
... (0 Replies)
Hi All,
I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise.
Eg :
Select 'Query 1 output' from dual;
Select 'Query 2 output' from dual;
I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies
LEARN ABOUT SUSE
ocf_heartbeat_pgsql
OCF_HEARTBEAT_PGSQL(7) OCF resource agents OCF_HEARTBEAT_PGSQL(7)NAME
ocf_heartbeat_pgsql - Manages a PostgreSQL database instance
SYNOPSIS
pgsql [start | stop | status | monitor | meta-data | validate-all | methods]
DESCRIPTION
Resource script for PostgreSQL. It manages a PostgreSQL as an HA resource.
SUPPORTED PARAMETERS
pgctl
Path to pg_ctl command. (optional, string, default /usr/bin/pg_ctl)
start_opt
Start options (-o start_opt in pg_ctl). "-i -p 5432" for example. (optional, string, no default)
ctl_opt
Additional pg_ctl options (-w, -W etc..). (optional, string, no default)
psql
Path to psql command. (optional, string, default /usr/bin/psql)
pgdata
Path to PostgreSQL data directory. (optional, string, default /var/lib/pgsql/data)
pgdba
User that owns PostgreSQL. (optional, string, default postgres)
pghost
Hostname/IP address where PostgreSQL is listening (optional, string, no default)
pgport
Port where PostgreSQL is listening (optional, integer, default 5432)
config
Path to the PostgreSQL configuration file for the instance (optional, integer, no default)
start_opt
Additional options passed to the PostgreSQL server daemon. (optional, string, no default)
pgdb
Database that will be used for monitoring. (optional, string, default template1)
logfile
Path to PostgreSQL server log output file. (optional, string, default /dev/null)
stop_escalate
Number of shutdown retries (using -m fast) before resorting to -m immediate (optional, integer, no default)
SUPPORTED ACTIONS
This resource agent supports the following actions (operations):
start
Starts the resource. Suggested minimum timeout: 120.
stop
Stops the resource. Suggested minimum timeout: 120.
status
Performs a status check. Suggested minimum timeout: 60.
monitor
Performs a detailed status check. Suggested minimum timeout: 30. Suggested interval: 30.
meta-data
Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5.
validate-all
Performs a validation of the resource configuration. Suggested minimum timeout: 5.
methods
Suggested minimum timeout: 5.
EXAMPLE
The following is an example configuration for a pgsql resource using the crm(8) shell:
primitive example_pgsql ocf:heartbeat:pgsql
op monitor depth="0" timeout="30" interval="30"
SEE ALSO
http://www.linux-ha.org/wiki/pgsql_(resource_agent)
AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors)
resource-agents 1.0.3 07/05/2010 OCF_HEARTBEAT_PGSQL(7)