Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Jobs in the background

Status
Not open for further replies.

olli2003

Technical User
Jan 31, 2003
93
DE
Hello AIX-freaks

I'd like to solve a problem by starting a job in the background.
Therfore I've used the "&" at the end of the command,
f.ex. /opt/<APPL>/Sever/bin/server.sh &
The background job will start.
But if I want to close the terminal I've started from, there comes up the message "There are jobs running." and after the second "exit" the terminal will close and the application aborts. What's the problem?
Thanks a lot for your answer!
Kind Regards
Oliver
 
Hi,

Code:
nohup /path/to/your/script.ksh &

# no Hang up when you exit and close your terminal
 
Hi aau!

Sure, but you've to close the terminal directly after starting the process, during the nohup signal's sending.
If you press f.ex. the "ENTER" Button between starting the application and closing the terminal, the same happens:
(There are jobs running.)

Isn't it?

Thanks and Regards
Oliver
 
The message is advisory only, the job continues to run after you log off.
 
Hi,

No matter what shell says, it's just a remember that you have jobs in background. When you exit, the script is still runnining :

Here is a try
Code:
#ls
try.ksh
#nohup ./try.ksh &
[1]     18812
#Sending output to nohup.out

#ps -ef |grep tr[y]
    root 18812 74208   0 12:54:19  pts/3  0:00 sh -- ./try.ksh
#ps
   PID    TTY  TIME CMD
 18812  pts/3  0:00 sh -- ./try.ksh
 34378  pts/3  0:00 ps
 35806  pts/3  0:00 sleep 60
 74208  pts/3  0:00 -ksh
#ls
nohup.out  try.ksh
#cat nohup.out
I=5
ven  7 oct 12:54:19 DFT 2005
#cat try.ksh
I=5
while [ $I ]
do
        print "I=$I" 
        date
        sleep 60
        (( I = I - 1 ))
done
#exit
You have running jobs
#exit

Déconnecté de l'hôte

reconnect

Code:
#ls
nohup.out  try.ksh
#cat try.ksh
I=5
while [ $I ]
do
        print "I=$I"
        date
        sleep 60
        (( I = I - 1 ))
done
#ps -ef |grep tr[y]
    root 18812     1   0 12:54:19      -  0:00 sh -- ./try.ksh
#ps
   PID    TTY  TIME CMD
 28508  pts/0  0:00 ps
 70648  pts/0  0:00 -ksh
#cat nohup.out 
I=5
ven  7 oct 12:54:19 DFT 2005
I=4
ven  7 oct 12:55:19 DFT 2005
I=3
ven  7 oct 12:56:19 DFT 2005
I=2
ven  7 oct 12:57:19 DFT 2005
I=1
ven  7 oct 12:58:19 DFT 2005
#
After reconection, my script try.ksh was still running and producint its output to nohup.out.
It is owned by init process ( process id 1 ) when I was disconnected
 
Wierd aau, that's almost exactly how I tested this before posting the above!
 
Hi,

The try.ksh was running so much that it did not stop when 'I' was equal to 0.
Some mix in my head of shell, C & co.
 
I start those types of commands with the at command - at 1301 /script.sh. I pick a time that will begin almost immediately. I send the error - and standard out to a file so I can trouble shoot any problems with the script. That works at least as well as the nohup and the &
 
thanks for all! ! ! great!

Have a nice weekend ,

Oliver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top