0

I made a script for this question Monitor an internet link to a remote host this script will be run by cron and, every minute or so, it will reexecute the commands

route add ....
route del ....

I know that if you add the same route twice there's an error message saying the file already exists, and if does not exist an error message saying the file does not exist.

Is there any reason I should avoid executing this command in those cases, or does it have no impact on network or machine performance at all?

  • There is one question you should ask yourself: "What if the route exists because another process / system configuration / router announcement created it? Should my cron job still delete the route?" It could become really frustrating if someone decides to make this route permanent but it keeps disappearing every minute or so. – Dubu Jul 3 '14 at 11:32
  • @Dubu in this case, the root are maintain statically by ourselves and no process at all are suppose to change anything to routing – Kiwy Jul 3 '14 at 11:34
  • At the moment, yes. But this could change. And then you are either prepared (by only adding&removing the route in the cron job if it didn't exist before) or have a good documentation. Well, in fact, you should document it anyway. :-) – Dubu Jul 3 '14 at 11:59
  • @Dubu well all the point of this script is to remove existing route and replacing them by others. you may have see the comment in the script and more over there will be some documentation in our db – Kiwy Jul 3 '14 at 12:02
1

If you add a route twice and then check it with the route command then you'll still only see one entry. That is, the second time you ran it, nothing was added. Similarly, once you've removed a route, you cannot remove it again.

If you don't like the error message, modify your script so that it runs route first and checks the results (using grep maybe) to see if the route is already configured.

Alternatively (and less elegant) redirect the stderr of your route add/del commands to /dev/null so that you don't see it.

  • well as long as it can't impact network connectivity or performance of the machine I don't mine an error message – Kiwy Jul 3 '14 at 10:48

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.