The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 13 03-06-2009 07:33 AM
Can a child process return a specific value to a parent process ? Ametis1970 High Level Programming 8 04-09-2008 11: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 07: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 12:54 PM
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-05-2006 02:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-23-2008
rein rein is offline
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.
  #2 (permalink)  
Old 07-23-2008
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0