Where will be nohup file created/stored - linux

On executing below given command within a script file:
Command :
nohup /usr/hp/ism/jboss-3.2.8.SP1/bin/run.sh &
Where will the nohup.out file be created, assuming that script is running in root directory ?

Could you check home directory.
also you can redirect as below;
nohup /usr/hp/ism/jboss-3.2.8.SP1/bin/run.sh &> /tmp/nohup.out
man nohup ;
If standard input is a terminal, redirect it from /dev/null. If
standard output is a terminal, append output to 'nohup.out' if
possible, '$HOME/nohup.out' otherwise. If standard error is a
terminal, redirect it to standard
output. To save output to FILE, use 'nohup COMMAND > FILE'.

Running a python code using nohup and & the nohub.out was in the same directory as the command was run from
pwd output:
/home/dv/project7
command run:
nohup python3 /home/dv/project7/test_code_v3.1.py &
ls -l output:
test_code_v3.1.py
nohup.out
I think a better way is so that your program outputs to your own error log file vs. stdout thgerefore to nohub.out

Related

While writing shell script after nohup command script is stuck

I am writing a shell script
After the execution of nohup command it is not going to next line
Just getting stuck indefinitely after execution of nohup
I am giving following command in script
nohup ./myscript.sh & sleep 30s && tail -30f nohup.out | grep -i "my desired output"
What I am trying to do is
Running the script using nohup command
Sleep 30s
tail from nohup.out file
Then using the output from nohup.out file to find the string I want
after the execution of this command
It prints the desired string perfectly from the nohup.out file but
Afte the execution of this line it does not move forward
Please suggest a way to execute lines after this command

nohup command not working in chef resources

I am trying to execute
>nohup.out
nohup ./example.sh &
which comes under my main.sh file. I am calling the main.sh from my bash resource in Chef. However, the STDERR is thrown when I run the chef-client. Shouldn't it go to nohup.out ?
From nohup manual:
If standard input is a terminal, redirect it from /dev/null. If standard >output is a terminal, append output to 'nohup.out' if possible, >'$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it >to standard output.
So to have stderr redirected to nohup.out you should first redirect it to stdout:
nohup 2>&1 ./example.sh &

can't see nohup command's output when used with ssh

I am trying to run a jar onto a different server. So, in my current script I do ssh on that server, and then run the jar using nohup. But, nohup.out is not getting created on the new server. So, I am not able to catch errors.
If, I log into that server manually and then fire the jar, nohup.out gets created. Can someone please help with this?
Below is the command that I've written in my script:
sshpass -p $node_pwd ssh -n root#$node "sh -c 'cd mydir;nohup java -jar NodeStarter.jar config.properties > /dev/null 2>&1 &'"
Here, node is the server I am logging into.
node_pwd is the variable containing the password for that server.
nohup java -jar blah.jar > /dev/null 2>&1
In this example, you are redirecting your output from stderr to stdout, but you have already redirected your output from stdout to /dev/null.
The result is that you are piping both stdout and stderr to /dev/null
Output only goes to nohup.out if it has not already been redirected.
It is likely you are not using the same redirection parameters when running the command from the shell.

huponexit off and ampersand inputted - but program still close

[oracle#centos1 ~]$ shopt | grep hupon
huponexit off
[oracle#centos1 ~] sqldeveloper & -- program is being ran
With the above, it is already stated that there will be no hup signal sent on exit. But when I close the shell, the program still gets closed.
Why ?
It's probably because sqldeveloper is attached to the terminal. nohup works because it detaches the command automatically — see this excerpt from nohup(1):
If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it to standard output. To save output to FILE, use 'nohup COMMAND > FILE'.
It should work without nohup if you do it by hand — try for example:
sqldeveloper < /dev/null &> /dev/null &

Linux: Daemon and Daemon output to be logged in a file

I am using the below command to run my python code as a daemon on the server.
nohup python mycode.py >> log.txt 2>&1 &
For some reason unknown to me only few lines are getting written to the file.
Thanks in advance
nohup itself writing output in nohup.out so no need to redirect output to log.txt,bydefault all output will be redirected to nohup.out

Resources