The problem arises because the current release is used by executing scripts, all of which are mvn packaged, while execution causes problems.
The solution checks, locks 、、、 before the script executes
#!/bin/bash{flock -n 3 if [ $? -eq 1 ]then echo "Other sh running" while [ 1 ] do flock -n 3 [ $? -ne 1 ]&&break; sleep 1 done 3<>/tmp/.lockfi echo "Lock and wait" Sleep 10} 3<>/tmp/.lock non-blocking mode, no lock, lock continues to execute down, there is a lock loop check, until there is no lock to continue execution. Options and Parameters:-S,--shared: Gets a shared lock that, during the time a shared lock is set on an FD directed to a file without releasing the lock, another process attempts to set an exclusive lock on the FD that is directed to this file to fail, while the other process attempts to set a shared lock on the FD that is directed to this file succeeds. -x,-e,--exclusive: Gets an exclusive lock, or write lock, for the default entry-u,--unlock: Manually release the lock, the general situation does not have to be, when FD shuts down, the system automatically unlocks, this parameter is used in the script command part of the asynchronous execution, part of the situation can be synchronously executed. -n,--nb, --nonblock: Non-blocking mode, when acquiring a lock fails, returns 1 instead of waiting for-W, --wait, --timeout seconds: Sets the blocking timeout, exits blocking mode when it exceeds the set number of seconds, returns 1, and resumes execution of the following statement-o, -- Close: An FD that closes the set lock before the command is executed so that the command's child process does not remain locked. -c, --command command: Execution of subsequent statements in the shell
This article is from the "Share,open source" blog, so be sure to keep this source http://liqilong2010.blog.51cto.com/3029053/1895513
Linux limits two shell scripts to execute simultaneously