2

Let say I have a KSH script my_script.ksh that performs complex operations including but not limited to invoking SQLPLUS to manipulate large number (millions) of records in an Oracle database. The script accepts a few parameters that determine which sets of records it will process and suppose it takes hours to manipulate each set of records.

I am now having an instance of the script running on the Unix server using NOHUP and & command options, that is to say that it's currently running in the background and is detached from the telnet session that I used to invoke the script.

Suppose I've modified the script locally on my desktop PC in order to make the subsequent executions of the script faster and to add some audit mechanism, and I am about to upload the script onto the server.

Will my uploading the modified version of the script affect the process that is currently running the script? I don't want to kill the process and start all over again on the current record set and I'm afraid to try and error since I can't be sure how destructive it would be. Any advise from experienced admin/user?

Lukman
  • 178
  • 5

3 Answers3

2

Any shell will be confused if you modify the script file while they are reading it. The problematic time window can be very small if the shell reads the whole script file before starting to execute it. I don't know whether ksh does that.

If you make sure to create a new file rather than modify the existing file, i.e., ln myscript myscript.running; mv -f myscript.new myscript (or any other method which moves the new script into place rather than modifying the existing file), you shouldn't have any problem.

1

Any ksh script will get it's own shell, all functions get loaded first, and then the script is interpreted. At run time. Any changes on disk made during execution will not be reflected in the currently running job.

nzwulfin
  • 174
  • 1
0

It won't work very well. If you modified your script while it's running, it's very likely to get a syntax error.

I've experienced it with bash and dash. I don't think it's that different from ksh. Even MS batch fails on this.

Lekensteyn
  • 6,111
  • 6
  • 37
  • 55