Looping entire bash scripts

Hey guys, Been a while hasn’t it?

I have - what could possibly be - an odd question. I have a script, written in bash, that i need to loop continuously not matter what the error status is. It’s purpous is to check whether a pppd interface is created and if not it forces a resync of the dsl lines it is attached to. How do i accomplish this?

Any ideas would be most helpful.



Write another bash script to call it in a loop. E.g.

while true

And if i wanted to make the loop script am init script i just need to add the correct syntax around the loop call, right?

No, you have to be careful with init scripts. If you intend to run something continuously, like a service, or your waiting script, you have to run it asynchronously so that your system startup can continue. Otherwise you will find your system will wait for your script to (never) complete and you won’t be able to boot up your system.

Do you have any suggestions then?

In the start) part of the init.d script:

     /full/path/to/the/loop/script/theloopscript &

It is the & the makes it an independent process.

Personal opinion: something like this would be better done as a discrete script that’s run as a cron job on regular intervals. If you’re trying to keep your DSL up and running, maybe 10 minute checks ought to do it.

The problem with a script that loops continuously, unless you renice it and/or put lots of sleep time in, is that it’s going to take processor time when it’s really not doing anything. Easier just to do a cron job.

Just my opinion, and worth exactly what you paid for it. :slight_smile:

I agree. It is often difficult to find out what peoples problems are. They embark for a certain direction and when stumbling into a sub-problem ask solution for that very sub-problem instead of asking for a direction/solution of their real problem.

But I support your solution for (what we think is) the real problem the OP has.

Thank you all for your suggestions but i have to say (and because of the nature of the project and who it is for) renicing is not nessecary and anything but constant checking is not acceptable. I can’t say anymore than this because this project is a minor part of a much bigger operation and i doubt anyone on this board has the clearance to see it but HCW’s suggestion should work nice.

FYI, I was a long standing member of SLS before the merger but since then and because of my work i have been unable to post but i can get away with this question because i’m only working on this one script and i was having a bad brain day.

Anyway, thanks again guys and hopefully i shall return in a more helpful role in the future.