Home > OS >  Consult the cycle bash how to write good, have the code, please advise, thanks!
Consult the cycle bash how to write good, have the code, please advise, thanks!

Time:09-21

#! Bin/bash
Nohup python/var/FTP/pub/abc111_xx py & gt; The/var/FTP/pub/abc111_xx. Log 2 & gt; & 1 & amp;
Sleep 1
Nohup python/var/FTP/pub/abc222_yy py & gt; The/var/FTP/pub/abc222_yy. Log 2 & gt; & 1 & amp;
Sleep 1
Nohup python/var/FTP/pub/abc333_xx py & gt; The/var/FTP/pub/abc333_xx. Log 2 & gt; & 1 & amp;
Sleep 1
Nohup python/var/FTP/pub/abc444_yy py & gt; The/var/FTP/pub/abc444_yy. Log 2 & gt; & 1 & amp;
Sleep 1


Follow-up may be abc555_xx abc666_yy etc., you need to modify the sh file,
But I don't want to have new py files, modify the sh file, so I want to in sh batch run these regular py files,

How do I use a regular and circulation to write this batch running program? Thank you!

CodePudding user response:

#!/bin/bash
X=111
Y=/var/FTP/pub
While true
Do
A=$x % 2
If [$a - eq 0]; Then
Nohup python $y/ABC - $x_yy. Py & gt; ABC - $$y/x_yy. Log & gt; 2 & amp; 1
The else
Nohup python $y/ABC - $x_xx. Py & gt; ABC - $$y/x_xx. Log & gt; 2 & amp; 1
Fi
Let "x +=111
"The done

A shot in the writing, change yourself