Without knowing any actual details of what your script does or contains, it's hard to give you a definitively correct answer here. But in terms of a general principle, you could process each IP in a loop, run your script for each IP in the background, then wait a number of seconds before proceeding to the next one in the loop. That way at least you would be able to continue with each IP in the list.
So for example, something like this:
Now I'm making a great deal of assumptions here, since you haven't given us any actual code of your own or any details about what precisely you're trying to do to each IP. But the above code fragment would iterate through every IP address in the file ip-list.txt and run the external script ./script.sh on it in the background. It would then pause for five minutes (300 seconds), and proceed regardless of the outcome with the next one in the list.
There are many potential problems with this approach, but this is about as generic a solution as I can suggest without anything detailed to actually go on. Hope this helps.
I am actually look at ways to restart a process if it hangs.
The line I highlighted in red sometime work, it will continue to the next line.
If it doesn't work,I would expect a way to restart that line first before proceeding to the next line.
Hope you can advise.
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
Rather than waiting for something to finish before starting the next task, I find that pdsh performing remote tasks in parallel is most useful for our situation. There is a timeout option (along with many other options).
Some details for pdsh (which calls pdsh.bin):
See man pdsh, and note that there are several alternate codes that may be considered as a result of searching for alternatives to pdsh -- for example see:
I am actually look at ways to restart a process if it hangs.
The line I highlighted in red sometime work, it will continue to the next line.
If it doesn't work
The problem is: we do not really know what "doesn't work" means. If it is that the quoted line just hangs and doesn't finish: start it in the background and have a wait command at the end collecting all the hanging processes. There are a lot of threads here dealing with exactly this problem.
If you mean by "doesn't work" that the process just comes back unsuccessfully: usually a process has a return code. You can query this return code and re-run the process if it is not zero (0 usually means it was successful and everything else some sort of failure).
Replace the quoted line with something like this:
This will try MAXRETRIES times to execute the code until it is either successful or the number of tries run out.
When I run script listed below it causes my Linux to hang. When it freezes I can do totally nothing, move cursor, switch to another terminal or whatever. Linux is just not responding and the only way out I know is a hard reset of PC.
#!/bin/bash
if ; then
echo "one parameter is needed: IP... (3 Replies)
script:
while read inputline; do
if ; then
if ; then
break
fi
fi
done
Looks like the script hangs when stdin is empty or contains space. Any ideas on how to circumvent this? is it possible to use getline to process stdin content? (4 Replies)
Hi,
I have script which is based on TCL and expect. It is written to test my code. It usually runs fine for a while and hangs after sometime.
Code snippet
set l_temp_timeout $timeout
OUTPUT_LOG2 2 >>>$expect_out(buffer)<<<
OUTPUT_LOG2 2... (2 Replies)
I am running solaris 8 on a sparcs box. The system is connected to a lightwave console server. I have a script that hangs when sending output to '/dev/console'. Any ideas?
-V (2 Replies)
I am trying to figure out a way to proceed through a menu-based program in UNIX with just one command to execute several steps. Is this possible?
From the command prompt I would normally type the name of the program, 'disk_analysis' to start the program and bring up its menu.
I would then... (4 Replies)
Hi
I need to run a shell script from a TCL script,the shell script in trun will run a python script
1.Tcl script
set filename "./GopiRun.sh"
2.GopiRun.sh
python ./psi.py $MYSB/test_scripts/delivery/gpy1.py
3.I have my gpy1.py script.
Here the problem i am facing is on running... (0 Replies)
Hi all,
I have made a script which logins to remote servers and fetches some data from it.
Is is working perfectly when all servers are reachable
BUT
my problem is -- if in case a server is down (or not reachable), the script hangs.
Is there some way, that the script just continues to ssh... (6 Replies)
I have a script that calls several other scripts in a specified order:
# Loop over actions in specified order (STOP_ORDER or START_ORDER) and build and evaluate commands
for command in $(eval print '$'${action}_ORDER)
do
printf "`date`\tExecuting ${action}_${command} = `eval print... (1 Reply)
We have a unix script scheduled to execute once in a day, some times it hangs on the server and never performs its operations, we need to manually kill the process and re-start that script, is there any way to have notification when the script hangs on the server.
Thanks & Regards,
Murthy. (3 Replies)