1836355 Members
2187 Online
110100 Solutions
New Discussion

"nohup" command

 
SOLVED
Go to solution
Brad Woolard
Occasional Contributor

"nohup" command

Is the nohup command supposed to stay active after a user logs out? If I type the following command it doesn't stick when the user logs out.

(nohup stty 19200 opost onlcr parenb parodd cs8 ixon -istrip clocal tab3; sleep 200000000)
If anyone has ideas on keeping serial ports open by a different means than the command I issued earlier, I would be glad to give it a try. We have to print checks directly to a device, in case anyone's wondering why I'm bypassing the the print spooler.

Thanks,

Brad Woolard
Of all the things I've lost I miss my mind the most (OZZY)
11 REPLIES 11
Jean-Luc Oudart
Honored Contributor

Re: "nohup" command

We have a similar script for same reason.
It works fine.
What is the pb ?

nohup(1) nohup(1)

NAME
nohup - run a command immune to hangups

SYNOPSIS
nohup command [arguments]

DESCRIPTION
nohup executes command with hangups and quits ignored. If output is
not redirected by the user, both standard output and standard error
are sent to nohup.out. If nohup.out is not writable in the current
directory, output is redirected to $HOME/nohup.out; otherwise, nohup
fails. If a file is created, the file's permission bits will be set to
S_IRUSR | S_IWUSR.

If output from nohup is redirected to a terminal, or is not redirected
at all, the output is sent to nohup.out.



Jean-Luc
fiat lux
Brad Woolard
Occasional Contributor

Re: "nohup" command

The problem is it hangs up when the user logs out.

I have to kill the shell process for the user's nohup command to stay intact. If I logout the user that issued the command the printer goes haywire again and prints gibberish.

-Brad
Of all the things I've lost I miss my mind the most (OZZY)
Jean-Luc Oudart
Honored Contributor

Re: "nohup" command

I think you nohup the stty but *NOT* the sleep command...
review your command
Jean-Luc
fiat lux
Sajid_1
Honored Contributor

Re: "nohup" command

Yes, nohup will keep the programs running even if you logout the session. Do you just want to print to a serial printer?
learn unix ..
Brad Woolard
Occasional Contributor

Re: "nohup" command

Yes, I owuld like to print to the serial printer directly, b/c of the program that utilizes the printer dictactes direct device communication.

-Brad
Of all the things I've lost I miss my mind the most (OZZY)
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: "nohup" command

Here's one way to solve it using a small bit of C that I have used for over 20 years to hold a serial port open. I spent about 2 minutes modifying it so that it will compile with the bundled (K & R) C compiler (in case you don't have anything better).

I would add this to /sbin/init.d/Sxxx. You can follow this up will a stty command (preferably in background in the same /sbin/init.d script)to set any other attributes you like.

Compile it like this:

cc holdport.c -o holdport

That will produce a 'holdport' executable.

Invoke it as simply 'holdport' for full usage but typically it would be:

holdport -t /dev/c2a2_lp -s 19200
If it ain't broke, I can fix that.
Sajid_1
Honored Contributor

Re: "nohup" command

hi again,

This document has better options with nohup:
http://support1.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000047674073

Doc ID - S3100002427
learn unix ..
Sajid_1
Honored Contributor

Re: "nohup" command

hello,

Another document that will do the same function:
http://support1.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000047992625

Doc ID - KBRC00000859
learn unix ..
Jeff Schussele
Honored Contributor

Re: "nohup" command

Hi Brad,

Is there a reason why this can't be setup in /etc/inittab - specifically to use the respawn feature?

Could look something like:

cklp:23:respawn:/usr/bin/stty 19200 opost onlcr parenb parodd cs8 ixon -istrip clocal tab3 < /dev/c2a2_lp

I've never set something up like this, but in theory I think it should work.

See man inittab for further details.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Brad Woolard
Occasional Contributor

Re: "nohup" command

Awesome responses! I will have to try all of these when I get time to do the testing. We're starting a check run now, but I'm sure when I do try the hold port executable, I will be in business.

Thanks again to all,

Brad Woolard
Of all the things I've lost I miss my mind the most (OZZY)
Todd Larchuk
Advisor

Re: "nohup" command

It's been many years since I abandoned the "nohup" command. I NEVER got it to work
correctly under ANY circumstances. Instead I now use "at", which ALWAYS has work great for me and is totally immune to hang-ups.