The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script to monitor process running on server and posting a mail if any process is dead pradeepmacha Shell Programming and Scripting 12 10-17-2008 12:08 AM
Can a child process return a specific value to a parent process ? Ametis1970 High Level Programming 8 04-09-2008 08:22 PM
Killing of a process and send a mail if the process doesnot come up within 2 minutes Prince89 Shell Programming and Scripting 1 02-15-2008 04:10 PM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 09:54 AM
my process is going to sleep mode after 12 hours but i need my process in in firsy pr mukesh_rakesh1 UNIX for Advanced & Expert Users 0 09-04-2006 11:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-23-2008
Registered User
 

Join Date: Dec 2004
Location: Zürich
Posts: 146
daemonize a process using ksh

I'm trying to create daemon processes with ksh as follows:


Code:
function start 
{
   # start script as co-process and pass an argument
   ./1.ksh $1 |&

   # print pid
   print $!
   
   # move the file descriptors of the co-process to 4 and 5 
   exec 4>&p
   exec 5<&p

   # then close them
   exec 4>&-
   exec 5<&-
}


for server in $servers
do
   start "arg1"
done
If script 1.ksh only contains a sleep, then it works. But if I have multiple statements, several ssh calls that take a while (>10min) for example, than the 1.ksh scripts just exits without finishing. This happens shortly after the calling script has finished. If I keep the calling script open they finish correctly. After the child scripts have finshed the calling script also finishes.I added the following after the call to the start routine:

Code:
while read -ru5 
do
   print -r $line
done
(and I commented out the closing of the file descriptors)

than it works. I want the 1.ksh processes to become daemon processes and finish and I want the calling script to exit.

I run it on a SunOS 5.8 server with ksh 88.
Reply With Quote
Forum Sponsor
  #2  
Old 07-23-2008
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
That won't daemonize anything. Put a command "ps -f > /tmp/ps.out" in the script you think is a daemon. Look at the output. See ? in the TTY field? If not, the script is not a daemon. That is the definition of a daemon.. no controling terminal.

To daemonize ksh.1 do:
echo /path/to/ksh.1 | at now
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 01:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0