Advice needed on using Script with NOHUP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Advice needed on using Script with NOHUP
# 1  
Old 03-11-2010
Advice needed on using Script with NOHUP

All,

I would like to know my below requirement can be achieved in any way in Shell Scripting? I will make this requirement of mine as understandable as I can.

Requirement:
I wrote a script 'my.script' which gets user-input tablenames and puts the same into an array. Also I get other inputs like logon credentials, Source Database name etc.

I process all the inputs to generate a 'fexp.exec' script on the fly. Then I am trying to execute the 'fexp.exec' script from 'my.script', to start the FastExport process (Teradata Utility to unload the source DB tables to the Unix environment as files). And once 'fexp.exec' script (FastExport) completes, the control returns back to the 'my.script' where I am validating the output files (created from the FastExport) based on the entered input files.

This whole effort is to automate the Unloading of tables from DB to Unix. Before writing the 'my.script', I used to prepare the 'fexp.exec' script manually and run it with a NOHUP (something like the code below), so that i can allow it to run in the background (as FastExport runs for 2 hours).

Code:
nohup ksh fexp.exec &

Question:
But now with this effort to automate, I have a requirement to run the 'fexp.exec' script from 'my.script'. And I want the 'fexp.exec' script to be run in the background. Also I do not want to make the my.script run for 2 hours as well!

I know I can just give the above line of code in my 'my.script' file to run the FastExport in the background. But I have the validation of the output files (created from FastExport) based on the entered input files, in 'my.script'. And immediately once after nohup of 'fexp.exec', the validation part in 'my.script' continues and it fails as the output files are not present as the fexp.exec is still running in the background.

To resolve this I see a few ways, but none of them are fruitful. I would need some advise on how to proceed with my condition here!

1. I can put a wait command after the nohup of fexp.exec, but that would make the my.script to wait for 2 hours, which I dont need.

2. I can nohup the my.script file itself but the script accepts user-input in various parts of the script.

3. I tried to echo the validation part into the fexp.exec script after the FastExport commands, so that I can just nohup the 'fexp.exec' and allow the my.script to run to completion once fexp.exec is nohup-ed. For this I have to pass the array that I received in my.script to fexp.exec. But that again is not working. I can post the code for this if you want.

Is there anyother way to achieve my requirement. I am sorry for writing a long story here. Hope I am not confusing anyone. Please let me know if you have any questions. Any help is very greatly appreciated.

p.s: I can post the code for the requirement or the #3 above, if anyone needs it for more understanding. i am not posting the code now just to prevent my post being toooo long Smilie

Thanks
Bharath
# 2  
Old 03-11-2010
So, you want the original process to terminate, while fexp.exec continues to run independently? If you're using the bash shell, the 'disown' command willl tell it not to wait for background processes to return before quitting, but otherwise I don't see why it would be hanging in the first place. It should just quit and let the background process continue.
# 3  
Old 03-11-2010
I do not need the original process to terminate but I would like it to wait in the background for the fexp.exec process (which again runs in the background) to complete and then run the validation part, again in background!
# 4  
Old 03-11-2010
nohup and background the original script when you run it then.
# 5  
Old 03-11-2010
That can be done but I the script 'my.script' accepts user-input in various parts of the script. And when I nohup the parent script, I am not sure of a way of getting user inputs
# 6  
Old 03-11-2010
That's why it hangs then: "waits on various user inputs", if not possible screen chatter to STDOUT. You'll want to refactor the overall interface to the script...but start by reviewing nohup.out in the directory where you'd run the nohup. It would carry the stdout by default...
# 7  
Old 03-12-2010
Perhaps in these user inputs you can include a method to tell it to detach itself? Because you can't have both. You have to close all open file descriptors to the terminal in order to close the connection without hanging on exit or killing the process.

Or you could use a system like screen. Screen keeps around sessions that you can connect to disconnect from, and reconnect to arbitrarily.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Solaris Study Advice Needed

I just have a question regarding learning Solaris, I have a Linux and AIX background and I would like to learn Solaris, I have been giving some Solaris 10 Study Guides and just wondered how relevant they would be to Solaris 11 or should I try and get some study materials which are targeted towards... (1 Reply)
Discussion started by: markmorris182mx
1 Replies

2. UNIX for Dummies Questions & Answers

Help needed for nohup time

Hi All, Firstly thanks for reading my query..I am a complete newbie in Unix and I recently read about nohup command which is responsible to continue execution in background. But I have found some command where time is used alongwith nohup as given below:- nohup time A.sh & I don't know why... (2 Replies)
Discussion started by: saswati16
2 Replies

3. Linux

Scripting advice needed

Evening all, Im trying to get a script that will: Select the most 3 recent files in a specific directory Run a command on them (like chmod) Ask of you would like to continue Copy the files to another directory If a linux guru could help me out, it would be very much appreciated. Thanks... (2 Replies)
Discussion started by: Wiggins
2 Replies

4. UNIX for Advanced & Expert Users

'for' loop advice needed....!!

Scenario: Command used to capture IPs on a host: /usr/sbin/ifconfig -a | grep "inet" | egrep -v "inet6|0.0.0.0|192.168.100.2" | awk '{print $2}' Following for loop used to capture interface names: for INTERFACE in `/usr/sbin/ifconfig -a | nawk '$1 ~ /:$/ && $1 {sub(":$", "", $1); print... (3 Replies)
Discussion started by: ak835
3 Replies

5. Shell Programming and Scripting

'for' loop advice needed ....!!

/usr/sbin/ifconfig -a | grep "inet" | grep -v "inet6" | grep -v "127.0.0.1" | grep -v "0.0.0.0"|grep -v "192.168.100.2" | awk '{print $2}' I use above command to get IP addresses on AIX boxes.Values coming here are set to a variable "Host IPs.IP Addresses" in my fingerprinting engine. ... (4 Replies)
Discussion started by: ak835
4 Replies

6. Filesystems, Disks and Memory

LVM resizing advice needed

Hi I have a CentOS 5 server with LVM. / and /home are low on disk space. I have ~12Gb available on /usr I plan to resize /usr and add the available space to the other 2 partitions. Please advice me on any precautions I need to take. Any problem if you have faced doing similar stuff and... (0 Replies)
Discussion started by: yunusyb
0 Replies

7. Linux

GUI builder advice needed ......

Hello all, I need to develop an application that would be used as a simulator to test various custom algorithms. As I have never embarked on this kind of work, I need some advice: 1. Which GUI library to use in Linux, GTK+ or FLTK? The simulator application needs to output various... (2 Replies)
Discussion started by: fox_hound_33
2 Replies

8. Shell Programming and Scripting

eval problem.. advice needed!

Hi I need some major help with eval I have a statement using eval: read input eval variable$input=”something” Now I want to use the “variable$input” in some commands but I don't know how to call it without replacing the $input with the command line value (which I obviously can't do). ... (1 Reply)
Discussion started by: Cactus Jack
1 Replies

9. Solaris

Using San storage - advice needed

Thinking of using our San for network backups.. Have a Netra 240 being installed and planning to get some space on our San. Do you know what software is used to access the San from my server or what I would need to do? I know how to connect to local storage, disk arrays etc but not sure what... (1 Reply)
Discussion started by: frustrated1
1 Replies

10. Linux

programming advice needed....

i'm a grad student taking a UNIX course and a networks course (i have a background in C++ and JAVA). i'm trying to combine the two classes. My questions stems from a networks programming homework assignment below: "Using the operating system and language of your choice, develop a program to... (5 Replies)
Discussion started by: trostycp
5 Replies
Login or Register to Ask a Question