nohup process does not get killed !!
hi ...
I call nohup in a script like follow but when I quite with ^c the stail program stil is in memory. as u can see I call a perl script within a shell script. Code:
#!/bin/bash Thanks in Advance.. |
Hi,
When you use nohup the program started (stail1.1.pl in this case) is detached from the terminal/shell and it will not react to any key combo's used in the original shell. Works as designed. Without knowing what it is you are trying to do and if the stail1.1.pl program actually does need a nohup (and be put to the back ground) I can't give you a solution. If stail1.1.pl finishes by itself you can probably remove the nohup (you might want to keep the &, depends....). If stail1.1.pl is an endless loop that must be stopped by the user you need some other solution, which depends on what the main script and the perl script do/must do. Hope this helps. |
Quote:
stail should be run while the main script is running. it produeces values that I need in main script (I actually sum these values with some other values and show them to the user). if stail not closed when the main script is closed, then it remain in memory and update the log file. so it case miscalculation when the main script run again. becuase now there two process (the old stail and new stail) are updateing a log file. I hope these details make the problem more clear. I realty appropriate your help. |
Hi,
The script you posted in post #1 only starts stail1.1.pl. Nothing is done with the output (all output is discarded due to the 1>/dev/null and 2>&1). Starting stail1.1.pl with nohup and putting it in the background (&) is probably not needed in your case. You probably need something like this: Code:
#!/bin/bash Hope this helps. |
Sorry if I couldn't clarify completely.
stail is like tail and has some built in functions that deal with output theselfs. the importatn thing is that it should be ran as the main script is running and close when the main is closed. the main script uses the an output file that stail will create as it is working |
Hi,
The example I gave does what you ask for. When you start the script (the example given in post #4), stail1.1.pl is started and the output is given, a line at the time, to the while read loop. Inside the while read loop you can do what you want/need with the individual lines. If you stop the example script (ctrl-c) the stail1.1.pl is also killed. Here's an example where stail1.1.pl is replaced by a tail -f on a log file. It looks for the word completed and prints the date/time and the process: Code:
#!/bin/bash Code:
first is example output generated by the tail -f process |
All times are GMT -5. The time now is 10:56 AM. |