Synchronizing four shell scripts to run one after another in unix

前端 未结 3 672
慢半拍i
慢半拍i 2021-01-15 22:39

I have 4 shell script to generate a file(let\'s say param.txt) which is used by another tool(informatica) and as the tool is done with processing, it deletes param.txt.

3条回答
  •  不要未来只要你来
    2021-01-15 23:02

    Thanks for your valuable suggestions. It did help me to think from other dimension. However I missed to mention that I am using Solaris UNIX where I couldn't find equivalent of flock or similar function. I could have asked team to install one utility but in mean time I found a workaround for this issue.

    I read about the mkdir function being atomic in nature where as 'touch' command to create a file is not(still don't have complete explanation on how it works). That means at a time only 1 script can create/delete directory 'lockdir' out of 4 and other 3 has to wait.

    while true;
    do 
    if mkdir "$lockdir"; then
       < create param file >
    
    break;
    fi
        Sleep 30
    done
    

提交回复
热议问题