Skip to content
Advertisement

Script takes parameters from the previous run

I am using docker container that runs Alpine Linux.It runs some bash script async

bash myscript.sh $param1 $param2 &>/dev/null &disown

The first time it runs it seems it does nothing it should write to some database but when I run it second time

bash myscript.sh $param3 $param4 &>/dev/null &disown

It does work but it use parameters from the previous run i.e param1 and param2.

Without &>/dev/null &disown it works fine from the first time

Could someone explain to me such behaivour

Advertisement

Answer

The solution was to add a delay

bash myscript.sh $param1 $param2 &>/dev/null &disown
sleep 1

Probably because it async the script finishes too fast But I would like to hear in depth explanation

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement