Or we can use the basic shell "jobs" command. Obviously we would need to build a counter into the loop to allow us to stop after a given amount of time.
Tip. The "ps -ef" command sequence posted assumes unique matches for the "grep". You are very likely to get false matches.
Confining the search to one pid with "ps -fp<pid>" would be safer and quicker.
Actually for anything mission critical I would never rely on "ps -ef" because it occasionally misses processes (or does not reply at all) when the kernel is busy.
Hello all,
How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename.
Any assistance is most appreciated.
Thanks,
Jim... (10 Replies)
Hi,
In shell script when I use
script1 >> filelog
the echo statments of script1 gets printed in the filelog
but when I try to run script in background i.e,
script1 & >> filelog
nothing gets printed in the filelog.
Anybody knows whats going on here.
thanks (3 Replies)
I'm having an issue when I export within my program. I'm getting the variable name, not the variable value. I have a configuration file (config.txt) that has the values of the variables set as so:
set -a
export ARCHIVEPOSourceDir="/interfaces/po/log /interfaces/po/data"
export... (2 Replies)
I ran the Oracle 9i export command from a terminal to export out a big table using "exp andrew/password file=andrew.dmp log=andrew.log"
From the terminal I can see that the export is running as there is some output from the oracle export job. The export job is not complete yet. When i go check... (4 Replies)
Hi All,
I have a script which calls a child script with a parameter to be run in the background
. childscript.ksh $a &
Can any one suggest me how do i export a variable from the child script to parent script?
Note that the child script is in background
If the child script is in... (3 Replies)
Hi guys, I have a issue with a background process, I need to update the value of a variable in that process which is running at this time and it will be running for at least 2 days.
Any idea?
I will apreciate your help. regards.
Razziel. (2 Replies)
What I need to learn is how to use a script that launches background processes, and then kills those processes as needed.
The script successfully launches the script. But how do I check to see if the job exists before I kill it?
I know my problem is mostly failure to understand parameter... (4 Replies)
Hi,
I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming.
So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
i have a script inside which i have generated a background job which will run another script.
How do i export the variables from parent script to the child script which wil run in the background .
a.sh:-
export tmpdir="/usr/tmp"
nohup b.sh&
b.sh:-
echo $tmpdir
But... (1 Reply)
Hi,
I have written a menu driven shell script in which as per the choice, I run the another script on background.
For eg:
1. get info
2)process info
3)modify info
All the operations have different scripts which i schedule in background using &.
However I wish to display the error... (0 Replies)
Discussion started by: ashima jain
0 Replies
LEARN ABOUT MOJAVE
tcl_waitpid
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)