I guess wait on LINUX waits for everything. I wonder if nohup helps to move the script away. It might be an interesting man page read or such, to find out whether it is waiting for all processes on the tty or on the process group. But yes, collecting pids and waiting for them one at a time is best, as you get the exit return $? of each child from "wait $child_pid".
If the exit status is not a biggie, or you check that through log files, you can skill the wait and monitor the children through shared stdout and stderr, like this:
This monitors not only the children but their children and so on, as long as they do not redirect both stdout and stderr. Even when "wait $child_pid" returns, the child may have antecedents still running, background or up-pipeline processes that close stdout but do not immediately exit, or someone down-pipeline exits cutting them off! $! is just the parent or last in pipeline pid.
The ability of processes other than $! to get errors not reported on $? is one reason to rely on logs, or write a very attentive wrapper script to keep an eye on the children and report $? for all. Sometimes I get really formal, for money and my job security and all that. This is fine for interactive, but not so wise unattended:
Last edited by DGPickett; 10-29-2010 at 12:52 PM..
I have a .sh script which was running fine on all the UNIX Servers (AIX, SunSolaris). The script requires two mandatory parameters and many optional parameters. Now at a different client place who are on a Windows Server, when I try to execute the script through MKS Toolkit, there are couple of... (5 Replies)
Okay, I have the following script that runs fine from a command line as well as an executable .sh file. It just moves any file/folder with movie* in the name to a folder called _Movies. The issue I'm running into is when it's call from a cron.
find /mnt/HD_a2/BT/complete -iname "movie.*" -exec... (4 Replies)
Hi,
My script is running with no erros but not giving any output can anyonehelp.
#!/bin/ksh
. /home/application/bin/application.env
OUTFILE=Result.txt
PROD_PASSWORD=`${GET_PWD} -f ${PWD_FILE_PATH} -s ${PROD_SERVER} -u ${PROD_USER}`
echo "1)To get the book last loaded details "
read... (7 Replies)
Hello all,
Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val:
> cat getnon0file.sh
#!/bin/bash
this="getnon0file.sh"
USAGE=$this"
InFile="xyz.38"
Min="0.05"
#
awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Hi, I'm new to these forums, and I'm hoping that someone can solve this problem...
To make things short:
I have DD-wrt set up on a router.
I'm trying to run a script in CRON that fetches the daily password from my database using SSH.
CRON is set like so(in web interface):
* * * *... (4 Replies)
Hello Guys,
I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following.
1) When I manually execute following script it runs successfully with below output.
bash-3.00# more smssend
#!/bin/bash
echo -e "<Request... (16 Replies)
Hello Team,
As a part of my job we have made a script to automate a service to restart frequently.
Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out.
They both start and run fine, but on the CRON it stops prematurely.
The script hits an API every few seconds and grabs data.
Does anyone have any idea on... (4 Replies)
Hi All,
I have a question related to Shell scripting. In my shell script, I have following two commands in sequence:
sed 's/^/grep "^120" /g' $ORIGCHARGEDAMTLIST|sed "s;$;| cut -f$FIELD_NO1 -d '|' | awk '{ sum+=\$1} END {printf (\"%0.2f\\\n\", sum/100)}' >$TEMPFILE
mv $TEMPFILE $ORIGFILE... (3 Replies)
#!/bin/sh
# This script returns the number of rows updated from a function
echo "The execution is starting ....."
sqlplus -silent $UP <<EOF
set serveroutput on
set echo off
set pagesize 0
VAR no_rows_updated NUMBER;
EXEC :no_rows_updated :=0;
DECLARE
CURSOR c_update is
SELECT * FROM... (4 Replies)
Discussion started by: LoneRanger
4 Replies
LEARN ABOUT MOJAVE
tcl_reapdetachedprocs
Tcl_DetachPids(3) Tcl Library Procedures Tcl_DetachPids(3)__________________________________________________________________________________________________________________________________________________NAME
Tcl_DetachPids, Tcl_ReapDetachedProcs, Tcl_WaitPid - manage child processes in background
SYNOPSIS
#include <tcl.h>
Tcl_DetachPids(numPids, pidPtr)
Tcl_ReapDetachedProcs()
Tcl_Pid
Tcl_WaitPid(pid, statusPtr, options)
ARGUMENTS
int numPids (in) Number of process ids contained in the array pointed to by pidPtr.
int *pidPtr (in) Address of array containing numPids process ids.
Tcl_Pid pid (in) The id of the process (pipe) to wait for.
int *statusPtr (out) The result of waiting on a process (pipe). Either 0 or ECHILD.
int options (in) The options controlling the wait. WNOHANG specifies not to wait when checking the process.
_________________________________________________________________DESCRIPTION
Tcl_DetachPids and Tcl_ReapDetachedProcs provide a mechanism for managing subprocesses that are running in background. These procedures
are needed because the parent of a process must eventually invoke the waitpid kernel call (or one of a few other similar kernel calls) to
wait for the child to exit. Until the parent waits for the child, the child's state cannot be completely reclaimed by the system. If a
parent continually creates children and doesn't wait on them, the system's process table will eventually overflow, even if all the children
have exited.
Tcl_DetachPids may be called to ask Tcl to take responsibility for one or more processes whose process ids are contained in the pidPtr
array passed as argument. The caller presumably has started these processes running in background and does not want to have to deal with
them again.
Tcl_ReapDetachedProcs invokes the waitpid kernel call on each of the background processes so that its state can be cleaned up if it has
exited. If the process has not exited yet, Tcl_ReapDetachedProcs does not wait for it to exit; it will check again the next time it is
invoked. Tcl automatically calls Tcl_ReapDetachedProcs each time the exec command is executed, so in most cases it is not necessary for
any code outside of Tcl to invoke Tcl_ReapDetachedProcs. However, if you call Tcl_DetachPids in situations where the exec command may
never get executed, you may wish to call Tcl_ReapDetachedProcs from time to time so that background processes can be cleaned up.
Tcl_WaitPid is a thin wrapper around the facilities provided by the operating system to wait on the end of a spawned process and to check a
whether spawned process is still running. It is used by Tcl_ReapDetachedProcs and the channel system to portably access the operating sys-
tem.
KEYWORDS
background, child, detach, process, wait
TclTcl_DetachPids(3)