Script - How to automatically start another process when the previous process ends?

Hi all,

I'm doing automation task for my team and I just started to learn unix scripting so please shed some light on how to do this:

1) I have 2 sets of datafiles - datafile A and B. These datafiles must be loaded subsequently and cannot be loaded concurrently.
2) So I loaded datafile A first. It will take long - hours to complete. I do not want to wait before I can load datafile B.
3) How to write script that will automatically pick up datafile B soon after datafile A finishes loading?

Please please help me.. I need to come out with this unix script as soon as possible.. Thanks guys..

btw I'm using ksh.

Write one script to parse them sequentially, and put them into the background using

$ nohup script &

Note that this way, your script won't be able to receive any user input, and all output goes to nohup.out. Detail can be found in the man page.

Hi,

simply use for loop

#!/bin/ksh

for file in datafileA datafileB
do
your code (to load the datafile)
done

execute the script using nohup commnad. (nohup script)

hey thanks frens.. im gonna try them first thing tomorrow cuz i'm already at home haha..

but keep the ideas coming in people.. thanks again

dbaccess << EOF
load from filea insert into blah;
load from fileb insert into bleh;
EOF

hi quirkasaurus.. thanks but the datafiles are not the data from database.. they are .txt files (located in a directory in the server) that contains raw data and the loader will process them into a meaningful data report.

it sounds like you're just over-thinking this...

Scripts do run sequentially.

Just write a script that does the first part . . .. then the second....
Just don't put anything into the background and it should work the way you want.

Do u mean if my script look like this (example):-
#!/bin/ksh
cp datafileA ../loader
cp datafileB ../loader

datafileA will load until finish (this usually take hours) before datafileB is loaded?

well, by "load", you mean "copy", yes.

hi i tried this but unfotunately datafileA and datafileB both goes to /load directory at the same time and get loaded into the sentry concurrently. this is not the correct behavior.

i think i understand now.

the "sentry" is an independent program that is looking for files in that directory...
then loads them.

So. When that load is finished... we want to then copy over the next file for loading.

One possible solution is to watch the process list with ps -deaf and see if you
can identify the process that does the actual loading.

If you can, we're halfway there.

Else... would it be possible for the loading process to move the file out of
that directory once it is complete?

How much control does the loading process have?

Another possibility is to query the database itself... and copy the new file
over once X number of rows have loaded into the target table.