Starting a network server after communication interface is up

  • Post author:
  • Post last modified:November 15, 2024
  • Reading time:2 mins read

If you have a program that communicates over the network interface, say, eth0 and you wish to start the program automatically after the system startup, you need to ensure that the program starts after the interface eth0 is up. For Linux systems using the Upstart process management daemon, this can be done by starting the program after the event net-device-up occurs for the interface eth0.

The interface eth0 emits the event net-device-up after it comes up and becomes available for communication. A sample job for starting the program using the Upstart process management daemon is,

      
# myserver - starting myserver after system startup    
#                                                           
      
description    "myserver - example"                         
author         "Yours truly <yt@example.com>"   
      
start on net-device-up IFACE=eth0                           
stop on runlevel [01S6]                                     
      
console output                                              
      
chdir /home/abc/prog/bin                                    
      
exec /home/abc/prog/bin/myserver                          

SEE ALSO

Karunesh Johri

Software developer, working with C and Linux.