test.sh in /root/folder
#!/bin/bash
echo "Hello" #Sample Code
Now in th same folder(/root/folder). I have created nohup_test.sh
#!/bin/bash
while true
do
sh /root/folder/test.sh
sleep 1
done
If ran the above file like this nohup sh nohup_test.sh &
. It will run in background and creates nohup.out
have the output of test.sh
which we can tail -f nohup.out
Now I want the above script nohup_test.sh to run start startup(automatically run at startup of OS).
I have created another file start.sh
in same directory (/root/folder/)
#!/bin/bash
nohup sh /root/folder/nohup_test.sh &
I followed one procedure HERE.
vi /etc/rc.local
Add the entry like below
# This script is executed at the end of each multiuser runlevel
/root/folder/start.sh || exit 1 # Added by me
exit 0
I think script is starting(Checked with ps aux | grep "nohup"
).But I didn't get the nohup.out
file. So, how can I get that file nohup.out
or I have to follow any procedure?
Thanks!
2>&1
, can you please explain that. – Veerendra K Sep 21 '15 at 17:272>&1
simply redirectssdterr
tostdout
, so that both output streams are saved in yournohup.out
file. Otherwise it could probably create anohup.err
file for the other stream as well if needed. – Byte Commander Sep 21 '15 at 17:47less
viewer for example, or thetail
command. – Byte Commander Sep 22 '15 at 09:46