Skip to main content
added 291 characters in body
Source Link
Murphy
  • 2.7k
  • 1
  • 16
  • 22

It would be much easier (read: more read- and maintainable) if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:

for i in 00 01 02 03 04; do nohup /path/to/workerScript.sh ${i} done 

If you want to keep the logic in a single script you can still use this approach:

if [ $# -eq 0 ]; then  for i in 00 01 02 03 04; do nohup $0 ${i}  done exit 0 fi # Rest of the logic follows 

It would be much easier if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:

for i in 00 01 02 03 04; do nohup /path/to/workerScript.sh ${i} done 

It would be much easier (read: more read- and maintainable) if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:

for i in 00 01 02 03 04; do nohup /path/to/workerScript.sh ${i} done 

If you want to keep the logic in a single script you can still use this approach:

if [ $# -eq 0 ]; then  for i in 00 01 02 03 04; do nohup $0 ${i}  done exit 0 fi # Rest of the logic follows 
Source Link
Murphy
  • 2.7k
  • 1
  • 16
  • 22

It would be much easier if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:

for i in 00 01 02 03 04; do nohup /path/to/workerScript.sh ${i} done