Adding a service to ubuntu networking

One of the scripts I run on my server monitors various log files and watches for signs of intrusion attempts.

I wanted the function to run at boot, but instead only let it run when the network is actually up which makes more economical sense and reduces my processor and hard drive usage (if only slightly).

Anyway, enough preamble. Here is how to do it:

The directory /etc/network/if-up.d/ is parsed when networking is started or restarted
The directory /etc/network/if-down.d/ is parsed when networking is stopped

If you add a link to the program you wish to run into one of these directories it will run at the appropriate time.

Remember to check if the process is already running and handle that by either terminating the existing process or aborting the creation of the new process.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge