0

This question already has an answer here:

I have a requirement to do a script for gather some data from one db and formatting according to a requirement, this should run by a scheduled cron job. but there should not be parallel runs. (If one process is running, then other should not start).

Help me to do this in bash scripting.

marked as duplicate by muru, Thomas, αғsнιη, Anthony Geoghegan, ilkkachu bash Jun 1 '18 at 9:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

You can use lock file. At script start check if lock file is already exist, if so exit, if not continue. When create lock file. execute your script. And before exit remove lock file. something like this:

if [ - f lock ] ; then
exit 1
fi
touch lock
your code
rm lock
  • With few changes, I could complete the work.. Thanks for great help ! – Ishara Kularatna Jun 4 '18 at 13:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.