I have a program that needs to be run in about 1000 instances, each in a different independent directory (/mnt/x_1, /mnt/x_2... /mnt/x_1000). What I'm currently doing is mounting /bin /dev and /etc in each directory, then copying bash-related libraries from /lib and /lib64 to each directory and running those processes in for loop with subshell:
for (1..1000): (cd /mnt/x_$1; chroot .; ./app) done
But there are some problems:
- After each iteration I have to press ctrl+x(exit), because chroot changes user to "I have no name" and nothing else can be done. The processess are starting though
- It is NOT stable, it can NOT be ran from startupscript in terraform environment
- Sometimes it doesn't start at all and hangs the system
The trick is that from ansible it works like a charm, but I can not use ansible in this env.