0

Hi I have a shell script which calls another script and I have locking mechanism inside main script.
Please check below code.
Does this mean that other script(/home/user/anotherscript.sh) will not be called and executed as long as script is locked by locking mechanism.

function funcexit() { 
 echo "Locked" 
 exit 1 
}
(
 flock -x -w 10 549 || funcexit
 bash /home/user/anotherscript.sh
 do some stuff
)

Please let me know the thougts...

asked Oct 29, 2014 at 4:37

1 Answer 1

2

The script line flock -x -w 10 549 || funcexit says: "try to get an exlusive lock on fd# 549, with maximum waiting time of 10 seconds, if successfully acquire the lock, continue with the next line, otherwise call function funcexit " thus, if the script can not acquire the lock in 10 seconds, funcexit will be called (thus exit).

answered Oct 29, 2014 at 4:49
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.