Synchronizing four shell scripts to run one after another in unix

前端 未结 3 655
慢半拍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 22:52

    You can use GNU Parallel as a counting semaphore or a mutex, by invoking it as sem instead of as parallel. Scroll down to Mutex on this page.

    So, you could use:

    sem --id myGlobalId 'create input file; run informatica'
    sem --id myGlobalId 'create input file; run informatica'
    sem --id myGlobalId 'create input file; run informatica'
    sem --id myGlobalId 'create input file; run informatica'
    

    Note I have specified a global id in case you run the jobs from different terminals or cron. This is not necessary if you are starting all jobs from one terminal.

提交回复
热议问题