GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Question abt nohup
Operating System - HP-UX
1849909
Members
3321
Online
104047
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2009 12:43 PM
04-24-2009 12:43 PM
Here is a snippet of the code -
start)
> if [ $running -eq 1 ] ; then
> > echo "JBoss already running (PID $pid)"
> > exit 1
> fi
> exec > /dev/null 2>&1
> rm -f $PID_FILE
> nohup $START_CMD $START_OPT &
The application is crashing quite frequently and I suggested that we capture the output of nohup in a file instead of sending it to /dev/null. But here folks are suggesting that nohup.out should be existing on the system which I couldnt locate after an exhaustive find. My argument is that its already going to /dev/null but they are saying that the wrapper scripts output is going to /dev/null and the commands output is going to nohup.out.
I have tried to look for nohup.out but couldnt find. Can u answer why?
Thanks,
Allan
start)
> if [ $running -eq 1 ] ; then
> > echo "JBoss already running (PID $pid)"
> > exit 1
> fi
> exec > /dev/null 2>&1
> rm -f $PID_FILE
> nohup $START_CMD $START_OPT &
The application is crashing quite frequently and I suggested that we capture the output of nohup in a file instead of sending it to /dev/null. But here folks are suggesting that nohup.out should be existing on the system which I couldnt locate after an exhaustive find. My argument is that its already going to /dev/null but they are saying that the wrapper scripts output is going to /dev/null and the commands output is going to nohup.out.
I have tried to look for nohup.out but couldnt find. Can u answer why?
Thanks,
Allan
Solved! Go to Solution.
- Tags:
- nohup
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2009 01:28 PM
04-24-2009 01:28 PM
Re: Question abt nohup
>I have tried to look for nohup.out but couldn't find. Can you answer why?
Because it is already redirected to /dev/null with that exec. nohup(1) says:
If output is not redirected by the user, both standard output and standard error are sent to nohup.out.
nohup uses isatty(3) to check.
Because it is already redirected to /dev/null with that exec. nohup(1) says:
If output is not redirected by the user, both standard output and standard error are sent to nohup.out.
nohup uses isatty(3) to check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2009 02:24 PM
04-24-2009 02:24 PM
Solution
Hi Allan:
> My argument is that its already going to /dev/null but they are saying that the wrapper scripts output is going to /dev/null and the commands output is going to nohup.out.
No, the STDOUT and STDERR file descriptors have already been redirected to /dev/null by the 'exec'. Everything written to STDOUT and/or STDERR from here on goes there unless you manipulate the file descriptors again.
Consider this script:
# cat ./mysh
#!/usr/bin/sh
START_CMD=date
START_OPT=-u
exec > /tmp/mylog1.$$ 2>&1
rm -f $PID_FILE
nohup $START_CMD $START_OPT &
1>&-
exec > /tmp/mylog2.$$
echo "ok from STDOUT"
print -u2 "ok from STDERR"
...run as:
# ./mysh
# cat /tmp/mylog1*
cat /tmp/mylog1*
ok from STDERR
Fri Apr 24 22:18:59 UTC 2009
# cat /tmp/mylog2*
ok from STDOUT
The 'sh-posix' manpages will show you that '1>&-' closes file descriptor-1 (STDOUT) which is why we can then redirect it again.
Regards!
...JRF...
> My argument is that its already going to /dev/null but they are saying that the wrapper scripts output is going to /dev/null and the commands output is going to nohup.out.
No, the STDOUT and STDERR file descriptors have already been redirected to /dev/null by the 'exec'. Everything written to STDOUT and/or STDERR from here on goes there unless you manipulate the file descriptors again.
Consider this script:
# cat ./mysh
#!/usr/bin/sh
START_CMD=date
START_OPT=-u
exec > /tmp/mylog1.$$ 2>&1
rm -f $PID_FILE
nohup $START_CMD $START_OPT &
1>&-
exec > /tmp/mylog2.$$
echo "ok from STDOUT"
print -u2 "ok from STDERR"
...run as:
# ./mysh
# cat /tmp/mylog1*
cat /tmp/mylog1*
ok from STDERR
Fri Apr 24 22:18:59 UTC 2009
# cat /tmp/mylog2*
ok from STDOUT
The 'sh-posix' manpages will show you that '1>&-' closes file descriptor-1 (STDOUT) which is why we can then redirect it again.
Regards!
...JRF...
- Tags:
- redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2009 06:59 PM
04-24-2009 06:59 PM
Re: Question abt nohup
>JRF: '1>&-' closes file descriptor-1 (STDOUT) which is why we can then redirect it again.
Not "can" but probably "must", at least for stdin, stdout, stderr. When you redirect, it closes the file first.
So typically there isn't any need to do #>&-, unless you know you don't need it.
Not "can" but probably "must", at least for stdin, stdout, stderr. When you redirect, it closes the file first.
So typically there isn't any need to do #>&-, unless you know you don't need it.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP