By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,523 Members | 1,938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,523 IT Pros & Developers. It's quick & easy.

Detaching from controlling terminal

P: n/a

We are using PostgreSQL about two years beginning from version 7.0.
I have one question about starting postmaster:
Is there way to detach it from the controlling terminal under FreeBSD?

My situation: I start postmaster manually:

su pgsql -c "/usr/local/pgsql/bin/pg_ctl
-D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"

Log:
[1] LOG: database system was shut down at 2003-11-18 08:28:48 MSK
[2] LOG: checkpoint record is at 2/781889D0
[3] LOG: redo record is at 2/781889D0; undo record is at 0/0; shutdown TRUE
[4] LOG: next transaction id: 45635; next oid: 32885093
[5] LOG: database system is ready

and I see:

9655 p1 S+ 0:00,01 /usr/local/pgsql/bin/postmaster (postgres)
9657 p1 S+ 0:00,00 postmaster: stats buffer process (postgres)
9658 p1 S+ 0:00,00 postmaster: stats collector process (postgres)

It is attached to console p1. So when I press Ctrl+C in this console
postmaster writes and exits:

Log:
[1] LOG: fast shutdown request
[2] LOG: shutting down
[3] LOG: database system is shut down

When I reload server postmaster starts without any controlling terminal
and I can press Ctrl+C in any console I want:

178 con- I+ 0:00,16 /usr/local/pgsql/bin/postmaster (postgres)
180 con- I+ 0:00,00 postmaster: stats buffer process (postgres)
181 con- I+ 0:00,00 postmaster: stats collector process (postgres)

So I repeat my question:
Is there way to detach it from the controlling terminal under FreeBSD?

--
Best regards Andrey Feofilactovich.

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Andrey Mosienko writes:
We are using PostgreSQL about two years beginning from version 7.0.
I have one question about starting postmaster:
Is there way to detach it from the controlling terminal under FreeBSD?

My situation: I start postmaster manually:

su pgsql -c "/usr/local/pgsql/bin/pg_ctl
-D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"


That should do it. What version are you using?

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #2

P: n/a
Peter Eisentraut wrote:

Andrey Mosienko writes:
We are using PostgreSQL about two years beginning from version 7.0.
I have one question about starting postmaster:
Is there way to detach it from the controlling terminal under FreeBSD?

My situation: I start postmaster manually:

su pgsql -c "/usr/local/pgsql/bin/pg_ctl
-D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"


That should do it. What version are you using?


PostgreSQL: 7.0.1 - 7.3.4
FreeBSD: 4.2 - 4.9

--
Best regards Andrey Feofilactovich.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #3

P: n/a
Andrey Mosienko writes:
su pgsql -c "/usr/local/pgsql/bin/pg_ctl
-D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"


That should do it. What version are you using?


PostgreSQL: 7.0.1 - 7.3.4


I'm sure somewhere in between there it didn't work and then it was fixed.
If in doubt, redirect all three file descriptors stdin, stdout, stderr
somewhere (possibly /dev/null), so they're not attached to the terminal.

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #4

P: n/a
Andrey Mosienko wrote:
We are using PostgreSQL about two years beginning from version 7.0.
I have one question about starting postmaster:
Is there way to detach it from the controlling terminal under FreeBSD?

My situation: I start postmaster manually:

su pgsql -c "/usr/local/pgsql/bin/pg_ctl
-D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"


You can either use pg_ctl or nohup. Using pg_ctl is recommended.

Shridhar
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #5

P: n/a
Shridhar Daithankar wrote:

Andrey Mosienko wrote:
We are using PostgreSQL about two years beginning from version 7.0.
I have one question about starting postmaster:
Is there way to detach it from the controlling terminal under FreeBSD?

My situation: I start postmaster manually:

su pgsql -c "/usr/local/pgsql/bin/pg_ctl
-D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"


You can either use pg_ctl or nohup. Using pg_ctl is recommended.


su pgsql -c "/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"
^^^^^^^
What is nohup?
--
Best regards Andrey Feofilactovich.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #6

P: n/a
On Tue, 18 Nov 2003, Andrey Mosienko wrote:
What is nohup?

[craig@crucw craig]$ man -k nohup
nohup (1) - run a command immune to hangups, with output to a non-tty
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #7

P: n/a
Andrey Mosienko wrote:
Shridhar Daithankar wrote:
Andrey Mosienko wrote:

We are using PostgreSQL about two years beginning from version 7.0.
I have one question about starting postmaster:
Is there way to detach it from the controlling terminal under FreeBSD?

My situation: I start postmaster manually:

su pgsql -c "/usr/local/pgsql/bin/pg_ctl
-D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"
You can either use pg_ctl or nohup. Using pg_ctl is recommended.

su pgsql -c "/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"
^^^^^^^


Damn.. Sorry I missed that. Usually pg_ctl detaches from terminal. What is nohup?


When you start a job with nohup and put it in background, the job keeps running
even if terminal detaches.

When a terminal closes, a sighup is delivered to all applications started from
that terminal. Nohup just ignores it.

man nohup for more details.

Shridhar
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #8

P: n/a
On Tue, 2003-11-18 at 17:52, Shridhar Daithankar wrote:
Andrey Mosienko wrote:
Shridhar Daithankar wrote:
Andrey Mosienko wrote:
We are using PostgreSQL about two years beginning from version 7.0.
I have one question about starting postmaster:
Is there way to detach it from the controlling terminal under FreeBSD?

My situation: I start postmaster manually:

su pgsql -c "/usr/local/pgsql/bin/pg_ctl
-D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"

You can either use pg_ctl or nohup. Using pg_ctl is recommended.

su pgsql -c "/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start"
^^^^^^^


Damn.. Sorry I missed that. Usually pg_ctl detaches from terminal.
What is nohup?


When you start a job with nohup and put it in background, the job keeps running
even if terminal detaches.

When a terminal closes, a sighup is delivered to all applications started from
that terminal. Nohup just ignores it.

man nohup for more details.

Shridhar


Be aware that nohup lowers the priority of the process by default - this
can be undesirable for a server...

Stephen
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.