Could replacing a bash script with a new version cause a running instance of the script to fail

前端 未结 4 1029
轻奢々
轻奢々 2021-01-03 23:58

I am running bash scripts from java programs on a server. I just uploaded a new version of the script intending the next run of the script to use the version. I did not mean

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-04 00:22

    I'm not sure if things have changed since mob's answer, which has been accepted, but in bash 4.3.46 (such as comes with ubuntu 16.04), it is true that bash monitors the script file for changes, but this is broken if the file is deleted.

    So a slight modification to his script does the 'right' thing:

    # If you modify a script, will it change the behavior of
    # processes that are currently running that script?
    # Does this script print "Foo" or "Bar"?
    
    cat >foo.sh <foo.sh <

    This now prints Foo.

提交回复
热议问题