Help with write a master script to automatic 1000 process
Hi,
I just random create 1000 folder which range from 0-20,000 . Inside all the folder, I have copy over the same program named as run.sh to run in each folder.
Can I know that how to write a master script to let it automatic run the "run.sh" in each different random folder create?
Some random folder create :
If just run the "run.sh" in one folder, I will use the following command :
But it a bit tedious if I have 1000 different folder need automatic run the same program.
I was thinking do use "for ... do ... done ...", but I don't have much idea so far
Why don't you, inside the loop, cd into the directory represented by the loop variable, sh run.sh > run_log, and then cd back to the parent dir, ready for the next loop?
Unless we are missing something here your for .. do .. done loop will be like this:
Why copy run.sh to each folder?
You should be able to load the script from any path e.g. sh ../run.sh > run_log or sh ~/bin/run.sh > run_log.
Is each slightly different in some way?
I have thinking to do something like :
I just not sure is there any smarter way to edit the "for f in 500/ 18805/ 641/ ......
" instead of I list out all the 1000 folder name in first line?
Thanks for any advice.
---------- Post updated at 08:15 PM ---------- Previous update was at 08:13 PM ----------
Hi Chubler_XL,
can only run and work in each folder separately.
It can't run at any other path. That was because the input file in each folder is slightly different. But they all must use "run.sh" to extract out the result.
Hi Chubler_XL,
can only run and work in each folder separately.
It can't run at any other path. That was because the input file in each folder is slightly different. But they all must use "run.sh" to extract out the result.
I will try out your script.
Hope it works
Where the script is loaded from has no bearing on what directory it runs in, if you change to directory ./1008 and run /usr/local/bin/run.sh it will still execute in the 1008 folder even though the script is loaded from another folder. You will save yourself a lot of grief later if you keep 1 version of the script as you won't have to update 1000 different scripts for every change, try putting run.sh in a bin/ directory under your HOME and then run:
I think you will be pleasantly surprised.
This User Gave Thanks to Chubler_XL For This Post:
Dear Unix gurus,
We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Dear Unix gurus,
We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
I have an application desigend in PHP and MySQl running on apache web server that I is running on a Amazon EC2 server Centos. I want to implement the master-master and master slave replication and high availability disaster recovery on this application database.
For this I have created two... (0 Replies)
Hi All,
One of our servers stopped responding , unable to take any logins into it, the response is almost nil...later it resumed
Also during this time one of our application processes which was costly on memory got killed..is it an OOM kill?
Would like to know to know how to avoid such... (4 Replies)
Output file template format
<input_file_name>a</input_file_name>
<total_length_size>b</total_length_size>
<log_10_length_size>c</log_10_length_size>
Input_file_1 (eg. sample.txt)
SDFSDGDGSFGRTREREYWW
Parameter:
a is equal to the input file name
b is equal to the total length of... (2 Replies)
I'm new to expecting and i want to create a script to ssh to a device,check is a process is running and display that the process is running or not.This is what i have so far
After executing this script i get an error.
#!/usr/bin/expect
set timeout -1
set ip "machine ip goes here"
set... (5 Replies)
HI,
I'm using CentOS 5.1 x86_64, CPanel ..
a lot of my users used too much resource, i want to write a script to kill all of them.
Eg: LFD always notify me:
Time: Sun Apr 27 07:40:08 2008
Account: xxxx (my user)
Resource: Virtual Memory Size
Exceeded: 110 > 100 (MB)... (3 Replies)
I have a file that varies in the # of records. I want to read 1000 records, do something, read the next 1000 records, do something, going in 1000 increment chunks, and then finish up with whatever is left over at end of file. (1 Reply)
I am working on a project, which need to constantly watch the process, and check its status, if it was dead, it should be restart automatically.
Please kindly refer me to URL which teach how to write this kind of script, or service.
Thanks. (1 Reply)