Systemd services starting before network is up

I have a couple services that need the network to be up before they start. I have After=network.target in my .service unit. I have also tried After=netctl@ovh_net_eth0.service both did not work. Services error because no network when they are started. I have tried Google and searching the forums here and I am stumped.
Services
systemctl --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
cronie.service loaded active running Periodic Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
[email protected] loaded active running Getty on tty1
kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernel
netctl@ovh_net_eth0.service loaded active exited A basic static ethernet connection
sshd.service loaded active running OpenSSH Daemon
systemd-backlight@backlight:acpi_video0.service loaded active exited Load/Save Screen Backlight Brightness of backlight:acpi_video0
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-modules-load.service loaded active exited Load Kernel Modules
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-timesyncd.service loaded active running Network Time Synchronization
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
[email protected] loaded active running User Manager for UID 1000
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point
sys-devices-pci0000:00-0000:00:02.0-backlight-acpi_video0.device loaded active plugged /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0
sys-devices-pci0000:00-0000:00:1c.0-0000:01:00.0-net-eth0.device loaded active plugged 82574L Gigabit Network Connection
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loaded active plugged INTEL_SSDSA2CT040G3 1
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loaded active plugged INTEL_SSDSA2CT040G3 swap-sda2
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda.device loaded active plugged INTEL_SSDSA2CT040G3
sys-devices-platform-serial8250-tty-ttyS2.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS2
sys-devices-platform-serial8250-tty-ttyS3.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS3
sys-devices-pnp0-00:08-tty-ttyS1.device loaded active plugged /sys/devices/pnp0/00:08/tty/ttyS1
sys-devices-pnp0-00:09-tty-ttyS0.device loaded active plugged /sys/devices/pnp0/00:09/tty/ttyS0
sys-module-configfs.device loaded active plugged /sys/module/configfs
sys-subsystem-net-devices-eth0.device loaded active plugged 82574L Gigabit Network Connection
-.mount loaded active mounted /
dev-hugepages.mount loaded active mounted Huge Pages File System
dev-mqueue.mount loaded active mounted POSIX Message Queue File System
run-user-1000.mount loaded active mounted /run/user/1000
sys-kernel-config.mount loaded active mounted Configuration File System
sys-kernel-debug.mount loaded active mounted Debug File System
tmp.mount loaded active mounted Temporary Directory
systemd-ask-password-console.path loaded active waiting Dispatch Password Requests to Console Directory Watch
systemd-ask-password-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch
session-c2.scope loaded active running Session c2 of user concopa
cronie.service loaded active running Periodic Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
[email protected] loaded active running Getty on tty1
kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kern
netctl@ovh_net_eth0.service loaded active exited A basic static ethernet connection
sshd.service loaded active running OpenSSH Daemon
systemd-backlight@backlight:acpi_video0.service loaded active exited Load/Save Screen Backlight Brightness of backlight:acpi_video0
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-modules-load.service loaded active exited Load Kernel Modules
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-timesyncd.service loaded active running Network Time Synchronization
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
[email protected] loaded active running User Manager for UID 1000
-.slice loaded active active Root Slice
system-getty.slice loaded active active system-getty.slice
system-netctl.slice loaded active active system-netctl.slice

I tried adding "Requires=" still not working as planned. OVH dedicated box that had networking installed out of the box. I wonder if I need to do some tweaking there.  I just looked at boot log and services are starting before the network is up. Removed some lines to make it more readable. Dec 29 15:35:52 systemd[254]: Starting autodl screen irssi... is what I need to wait for network to be up before starting.
Dec 29 15:35:52 systemd[254]: pam_unix(systemd-user:session): session opened for user by (uid=0)
Dec 29 15:35:52 systemd[254]: Starting Paths.
Dec 29 15:35:52 systemd[254]: Reached target Paths.
Dec 29 15:35:52 systemd[254]: Starting Timers.
Dec 29 15:35:52 systemd[254]: Reached target Timers.
Dec 29 15:35:52 systemd[254]: Starting -.slice.
Dec 29 15:35:52 systemd[254]: Created slice -.slice.
Dec 29 15:35:52 systemd[254]: Starting Sockets.
Dec 29 15:35:52 systemd[254]: Reached target Sockets.
Dec 29 15:35:52 systemd[254]: Starting Basic System.
Dec 29 15:35:52 systemd[254]: Reached target Basic System.
Dec 29 15:35:52 systemd[254]: Starting autodl screen irssi...
Dec 29 15:35:52 systemd[254]: Started autodl screen irssi.
Dec 29 15:35:52 systemd[254]: Starting Default.
Dec 29 15:35:52 systemd[254]: Reached target Default.
Dec 29 15:35:52 systemd[254]: Startup finished in 156ms.
Dec 29 15:35:57 network[294]: Starting network profile 'ovh_net_eth0'...
Dec 29 15:35:57 kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Dec 29 15:35:58 kernel: e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
Dec 29 15:35:58 kernel: e1000e 0000:01:00.0 eth0: 10/100 speed: disabling TSO
Dec 29 15:35:58 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Dec 29 15:36:00 network[294]: Started network profile 'ovh_net_eth0'

Similar Messages

  • OpenVPN.service starts before network is up

    Hello,
    I have trouble getting an automatic OpenVPN connection at startup to work with systemd. Some troubleshooting revealed that OpenVPN always starts before the network is up (OpenVPN can't resolve the host adress).
    However, I think I have found why it does not work how I want it to:
    — dhcpcd.service - dhcpcd on all interfaces
    Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; enabled; vendor preset: disabled)
    Active: active (running) since Tue 2015-03-17 02:23:50 CET; 7min ago
    Main PID: 276 (dhcpcd)
    CGroup: /system.slice/dhcpcd.service
    └─276 /usr/bin/dhcpcd -q -b
    Mar 17 02:23:51 <system> dhcpcd[276]: wlp2s0: carrier lost
    Mar 17 02:23:51 <system> dhcpcd[276]: wlp2s0: deleting <address>
    Mar 17 02:23:53 <system> dhcpcd[276]: enp8s0: carrier acquired
    Mar 17 02:23:53 <system> dhcpcd[276]: enp8s0: IAID 0e:69:ff:09
    Mar 17 02:23:53 <system> dhcpcd[276]: enp8s0: rebinding lease of 192.168.32.44
    Mar 17 02:23:53 <system> dhcpcd[276]: enp8s0: soliciting an IPv6 router
    Mar 17 02:24:01 <system> dhcpcd[276]: enp8s0: leased 192.168.32.44 for 3600 seconds
    Mar 17 02:24:01 <system> dhcpcd[276]: enp8s0: adding route to 192.168.32.0/23
    Mar 17 02:24:01 <system> dhcpcd[276]: enp8s0: adding default route via 192.168.32.251
    Mar 17 02:24:06 <system> dhcpcd[276]: enp8s0: no IPv6 Routers available
    Whereas OpenVPN starts much earlier:
    Mar 17 02:23:54 <system> openvpn@<profile>[333]: <Process started plus can not resolve Host stuff>
    Mar 17 02:23:54 <system> openvpn@<profile>[333]: openvpn@<profile>.service failed.
    I tried using
    Wants=network-online.target
    After=network-online.target
    in the [email protected] and had enabled
    systemd-networkd.service
    systemd-networkd-wait-online.service
    but it still did not work as these services finished later as well:
    Mar 17 02:23:50 <system> systemd[1]: Started Network Service.
    Mar 17 02:23:53 <system> systemd-networkd[278]: enp8s0 : gained carrier
    Mar 17 02:25:19 <system> systemd-networkd[278]: tun0 : gained carrier
    Mar 17 02:23:51 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:51 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:51 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:51 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:51 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:51 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:53 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:53 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:53 <system> systemd-networkd-wait-online[298]: ignore irrelevant link: lo
    Mar 17 02:23:54 <system> systemd[1]: Started Wait for Network to be Configured.
    My guess is, that OpenVPN won't work until this has happened:
    Mar 17 02:25:19 <system> systemd-networkd[278]: tun0 : gained carrier
    I now tried to modify the .service like this (inspiration taken from this thread):
    [Unit]
    Description=OpenVPN connection to %i
    Requires:sys-devices-virtual-net-tun0.device
    After:sys-devices-virtual-net-tun0.device
    [Service]
    Type=forking
    ExecStart=/usr/bin/openvpn --cd /etc/openvpn --config /etc/openvpn/%i.ovpn --daemon openvpn@%i --writepid /run/openvpn@%i.pid
    PIDFile=/run/openvpn@%i.pid
    [Install]
    WantedBy=multi-user.target
    However, the status now looks as follows:
    — [email protected] - OpenVPN connection to stud-wh
    Loaded: error (Reason: Bad message)
    Active: inactive (dead)
    — sys-devices-virtual-net-tun0.device
    Loaded: loaded
    Active: inactive (dead)
    At this point I have no more ideas left. Can anyone confirm my suspicion that OpenVPN needs tun0 gained first? How can I check within a service wheter tun0 has been gained or not? Many thanks!
    Edit: The status of tun0 looks like this:
    — sys-devices-virtual-net-tun0.device - /sys/devices/virtual/net/tun0
    Loaded: loaded
    Active: active (plugged) since Tue 2015-03-17 03:00:52 CET; 17min ago
    Device: /sys/devices/virtual/net/tun0
    but when I try to enable it it says: Failed to execute operation: No such file or directory. This somehow contradicts the earlier status. I guess it got 'plugged' as I started the OpenVPN connection manually?
    Maybe OpenVPN has to wait for TAP aswell?
    Last edited by mrkernelpanic (2015-03-17 02:22:05)

    I just tried your suggestion again and changed the resolv-retry from 0 to 2. Now I have a PID error aswell:
    — openvpn@<profile>.service - OpenVPN connection to <profile>
    Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; vendor preset: disabled)
    Active: failed (Result: resources) since Tue 2015-03-17 03:29:59 CET; 42s ago
    Process: 284 ExecStart=/usr/bin/openvpn --cd /etc/openvpn --config /etc/openvpn/%i.ovpn --daemon openvpn@%i --writepid /run/openvpn@%i.pid (code=exited, status=0/SUCCESS)
    Mar 17 03:29:59 <system> openvpn@stud-wh[284]: OpenVPN 2.3.6 x86_64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Dec 2 2014
    Mar 17 03:29:59 <system> openvpn@stud-wh[284]: library versions: OpenSSL 1.0.2 22 Jan 2015, LZO 2.09
    Mar 17 03:29:59 <system> openvpn@stud-wh[284]: WARNING: file '/etc/openvpn/auth.conf' is group or others accessible
    Mar 17 03:29:59 <system> openvpn@stud-wh[284]: WARNING: file '/etc/openvpn/ta.key' is group or others accessible
    Mar 17 03:29:59 <system> openvpn@stud-wh[284]: Control Channel Authentication: using '/etc/openvpn/ta.key' as a OpenVPN static key file
    Mar 17 03:29:59 <system> openvpn@stud-wh[284]: RESOLVE: Cannot resolve host address: <hostaddress>: Name or service not known
    Mar 17 03:29:59 <system> systemd[1]: PID 295 read from file /run/openvpn@<profile>.pid does not exist or is a zombie.
    Mar 17 03:29:59 <system> systemd[1]: Failed to start OpenVPN connection to <profile>.
    Mar 17 03:29:59 <system> systemd[1]: Unit openvpn@<profile>.service entered failed state.
    Mar 17 03:29:59 <system> systemd[1]: openvpn@<profile>.service failed.
    The config looks like this:
    # <a number>
    client
    dev tun
    proto tcp
    ca /etc/openvpn/cachain.crt
    remote <hostaddress> 2711
    remote <hostaddress> 2712
    remote <hostaddress> 2713
    remote <hostaddress> 2714
    remote-random
    tls-remote <hostaddress>
    resolv-retry 2
    connect-retry 2
    #connect-retry-max 2
    connect-timeout 2
    nobind
    user nobody
    group nogroup
    persist-key
    persist-tun
    mute-replay-warnings
    tls-auth /etc/openvpn/ta.key 1
    auth-user-pass /etc/openvpn/auth.conf
    auth-retry interact
    comp-lzo no
    reneg-sec 43200
    Edit: Tried it with systemd-networkd.service enabled aswell. Not much of a difference:
    — openvpn@<profile>.service - OpenVPN connection to stud-wh
    Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Tue 2015-03-17 03:37:51 CET; 26s ago
    Process: 293 ExecStart=/usr/bin/openvpn --cd /etc/openvpn --config /etc/openvpn/%i.ovpn --daemon openvpn@%i --writepid /run/openvpn@%i.pid (code=exited, status=0/SUCCESS)
    Main PID: 306 (code=exited, status=1/FAILURE)
    Mar 17 03:37:51 <system> openvpn@stud-wh[293]: library versions: OpenSSL 1.0.2 22 Jan 2015, LZO 2.09
    Mar 17 03:37:51 <system> openvpn@stud-wh[293]: WARNING: file '/etc/openvpn/auth.conf' is group or others accessible
    Mar 17 03:37:51 <system> openvpn@stud-wh[293]: WARNING: file '/etc/openvpn/ta.key' is group or others accessible
    Mar 17 03:37:51 <system> openvpn@stud-wh[293]: Control Channel Authentication: using '/etc/openvpn/ta.key' as a OpenVPN static key file
    Mar 17 03:37:51 <system> openvpn@stud-wh[293]: RESOLVE: Cannot resolve host address: <hostaddress>: Name or service not known
    Mar 17 03:37:51 <system> openvpn@stud-wh[306]: NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay
    Mar 17 03:37:51 <system> systemd[1]: Started OpenVPN connection to <profile>.
    Mar 17 03:37:51 <system> systemd[1]: [email protected]: main process exited, code=exited, status=1/FAILURE
    Mar 17 03:37:51 <system> systemd[1]: Unit openvpn@<profile>.service entered failed state.
    Mar 17 03:37:51 <system> systemd[1]: openvpn@<profile> failed.
    Last edited by mrkernelpanic (2015-03-17 02:56:45)

  • Systemd service starts command twice

    Hello,
    i have a problem with systemd service for inotifywait check my mails.
    service:
    [Unit]
    Description=Start mailnotify as a daemon
    Requires=offlineimap.service
    After=offlineimap.service
    [Service]
    User=matija
    ExecStart=/home/matija/bin/mailnotify.sh
    [Install]
    WantedBy=multi-user.target
    and when i start it:
    sudo systemctl status mailnotify.service
    mailnotify.service - Start mailnotify as a daemon
    Loaded: loaded (/usr/lib/systemd/system/mailnotify.service; disabled)
    Active: active (running) since Wed, 2012-12-12 15:46:00 CET; 6s ago
    Main PID: 13650 (mailnotify.sh)
    CGroup: name=systemd:/system/mailnotify.service
    ├─13650 /bin/bash /home/matija/bin/mailnotify.sh
    ├─13652 /bin/bash /home/matija/bin/mailnotify.sh
    └─13653 inotifywait -e create -e moved_to /home/matija/Maildir/Archives.2012/new /home/matija/Maildir/Archives/new /hom...
    Dec 12 15:46:00 workarch systemd[1]: Starting Start mailnotify as a daemon...
    Dec 12 15:46:00 workarch systemd[1]: Started Start mailnotify as a daemon.
    but it doesn't work.
    when i start /home/matija/bin/mailnotify.sh it works as expected.
    Could you please help me with that?
    Thanks

    You'll have to run journalctl as root. It should be logged as UNIT=bar.service, SYSLOG_IDENTIFIER=systemd, one example from me:
    sudo systemctl start chrony.service
    sudo systemctl stop chrony.service
    sudo journalctl -o verbose --since today UNIT=chrony.service SYSLOG_IDENTIFIER=systemd
    Sa 2014-09-06 01:19:32.432387 CEST [s=###########################;i=#####;b=###########################;m=#######;t=##########;x=#############]
    PRIORITY=6
    _UID=0
    _GID=0
    _MACHINE_ID=###########################
    _HOSTNAME=pamobile
    SYSLOG_FACILITY=3
    SYSLOG_IDENTIFIER=systemd
    _TRANSPORT=journal
    _PID=1
    _COMM=systemd
    _EXE=/usr/lib/systemd/systemd
    _CMDLINE=/sbin/init
    _CAP_EFFECTIVE=3fffffffff
    _SYSTEMD_CGROUP=/
    CODE_FILE=src/core/job.c
    CODE_LINE=721
    CODE_FUNCTION=job_log_status_message
    MESSAGE_ID=#######################
    RESULT=done
    UNIT=chrony.service
    MESSAGE=Started Chrony Network Time Daemon.
    _BOOT_ID=############################
    _SOURCE_REALTIME_TIMESTAMP=###########
    Sa 2014-09-06 01:19:40.538847 CEST [s=###############################;i=#####;b=###############################;m=########;t=############;x=#########################]
    PRIORITY=6
    _UID=0
    _GID=0
    _MACHINE_ID=###############################
    _HOSTNAME=pamobile
    SYSLOG_FACILITY=3
    SYSLOG_IDENTIFIER=systemd
    _TRANSPORT=journal
    _PID=1
    _COMM=systemd
    _EXE=/usr/lib/systemd/systemd
    _CMDLINE=/sbin/init
    _CAP_EFFECTIVE=3fffffffff
    _SYSTEMD_CGROUP=/
    CODE_FILE=src/core/job.c
    CODE_FUNCTION=job_log_status_message
    RESULT=done
    UNIT=chrony.service
    CODE_LINE=729
    MESSAGE_ID=###############################
    MESSAGE=Stopped Chrony Network Time Daemon.
    _BOOT_ID=###############################
    _SOURCE_REALTIME_TIMESTAMP=###################

  • Systemd / services start but do not listen to interfaces

    Hello,
    In the course of migrating from initscripts to systemd (mixed systemd/sysvinit/initscripts), I am facing a strange behaviour with some services: squid, bind (named), dhcpd which start normally but do not listen to the useful interface. For instance, for named, netsat does not show  192.168.42.2:53 (which is is my LAN interface), despite the process is running (systemd status named). It seems that with systemd there is a change to the way available interfaces are reported to the services (for those services, I have not explicitly configured the interface to listen to).
    If I revert back to initscripts only (removing  init=/usr/lib/systemd/systemd from the kernel argument) everything is OK.
    I am not running NetworkManager (relevant ?), my rc.conf is clean apart that I am still using the deprecated syntax (I need a bridge interface that NetworkManager cannot handle).
    eth0="dhcp"
    eth1="eth1 promisc"
    br1="br1 192.168.42.2 netmask 255.255.255.0 broadcast 192.168.42.255"
    INTERFACES=(eth0 eth1 br1)
    Thanks for any help.

    mrechte wrote:
    I found the cause of the problem: legacy network service starts too late, after some other network daemons which do not see yet the interfaces.
    I switched to netcfg and dropped network.
    Seems to be OK now.
    Glad you found the problem. Would you please edit your first post and mark as "Solved" so others searching for this will see it?

  • Ntpd starting before network connection up.

    Hey I'm using open ntpd  to sync time on my computer. But it seems to be running before my network connection is up, therefore not syncing the time.
    I'm unfamiliar with systemd (and honestly, really despise it), so I'm having trouble fixing the problem. Here's the .service file:
    $ cat /etc/systemd/system/multi-user.target.wants/openntpd.service
    [Unit]
    Description=OpenNTP Daemon
    After=network.target
    [Service]
    Type=forking
    ExecStart=/usr/bin/ntpd -s
    [Install]
    WantedBy=multi-user.target
    Any ideas?

    NTPD should automatically resume after connection has been established. See systemctl, systemctl status ntpd, journalctl.
    You should see something like this
    May 25 22:55:39 arch ntpd[642]: new interface(s) found: waking up resolver
    May 25 22:55:42 arch dhcpcd[370]: enp4s0: leased 192.168.1.107 for 86400 seconds
    May 25 22:55:42 arch dhcpcd[370]: enp4s0: adding route to 192.168.1.0/24
    May 25 22:55:42 arch dhcpcd[370]: enp4s0: adding default route via 192.168.1.254
    May 25 22:55:43 arch ntpd[642]: Listen normally on 5 enp4s0 192.168.1.107:123
    May 25 22:55:43 arch ntpd[642]: new interface(s) found: waking up resolver
    May 25 22:55:50 arch dhcpcd[370]: enp4s0: no IPv6 Routers available
    May 25 22:55:51 arch systemd[715]: Time has been changed
    May 25 22:55:51 arch systemd[1]: Time has been changed
    If you want to visualize how NTP is running, I recommend installing Monitorix
    http://www.monitorix.org/imgs/ntp.png
    Last edited by Name Taken (2014-05-26 06:13:17)

  • Windows Embedded Standard 7 TCP/IP Services not completely started before user application loads

    WES7 is set to autologon a user and launch a startup batch that launches my application.  My application, through a series of LEDs, notifies the user when the system
    is initialized and ready to go.  What I've noticed is that even though the system is "up and running" TCP/IP services are not initialized yet.  For example, RDP Server won't respond as well as ICMP/ping and FTP services.  Sometime
    later, maybe 20-30 seconds Windows TCP/IP services come alive and everything is okay.  Once other thing to note is that I am using BIT Locker and when I turn it off, TCP/IP services, a majority of the time, are alive immediately at or around autologon.
     My guess is that there is some contention when Windows is logging and starting services and the behavior for which services are started when is not always deterministic.  Is there a way to guarantee TCP/IP services starting before other services?
     I’ve messed around with several services in service manager but none seemed to fix the problem.  One other item to note.  I was able to issue a ping as my first command in my startup script to a fixed IP which appears to force TCP/IP services
    to initialize.  The problem with this “hack” is that I don't know any host IP addresses until my system has fully started.  Plugging in the loopback address in the script or my own external IP did not work.
    Thanks,
    Joe

    I forgot this is getting trickier to track this for WES7. There was this method in C#:
    http://stackoverflow.com/questions/10855290/which-windows-service-ensures-network-connectivity
    Workstation Service or DHCP Service might be good enough. Firewall should be late enough that the network
    Of course there are other methods like doing a ping until a an address returns:
    http://serverfault.com/questions/612237/how-to-wait-for-network-in-a-batch-script-when-booting-on-windows-server
    Other implementations:
    https://social.technet.microsoft.com/Forums/windows/en-US/393e6042-dea0-4285-9aeb-2ddf50434f6b/windows-7-always-wait-for-the-network-at-computer-startup-and-logon-group-policy?forum=w7itpronetworking
    http://superuser.com/questions/262799/how-to-launch-a-command-on-network-connection-disconnection/262880#262880
    I have never tried this one since it is more for domains:
    Go to Start -> type in "gpedit.msc" in the run/search field.
    In the Local Group Policy Editor that pops up, go to "Computer Configuration" -> "Administrative Templates" -> "System" -> "Logon" -> "Always wait for the network at computer startup and logon"
    www.annabooks.com / www.seanliming.com / Book Author - Pro Guide to WE8S, Pro Guide to WES 7, Pro Guide to POS for .NET

  • Sometimes Network service is started before udev renaming interface

    Hello,
    I've configured my Nuc D34010WYKH2 with a bridge static ip address (used for virtualization with qemu-kvm). Sometimes, when i reboot the network service fails to start because the network interface is not yet renamed.
    Here is the systemd log :
    http://www.filedropper.com/journalctl2
    My network script /etc/systemd/system/network.service :
    http://pastebin.archlinux.fr/501234
    /etc/conf.d/network :
    http://pastebin.archlinux.fr/501235
    I have another problem like no hdmi sound and it seems i have acpi problems (system log)
    Last edited by Songohan (2014-04-23 19:15:02)

    Apr 22 23:13:52 nuc systemd[1]: Starting udev Coldplug all Devices...
    Apr 22 23:13:52 nuc systemd[1]: Started udev Coldplug all Devices.
    Apr 22 23:13:54 nuc brctl[252]: interface eno1 does not exist!
    Apr 22 23:13:54 nuc systemd-udevd[151]: renamed network interface eth0 to eno1
    That's odd. You would expect udev to settle before the rest continue's.
    I have it, look at comment #6 here. You need to instantiate (systemD jargon for multiplex) an ifplugd service file from netctl.
    A different alternative is to add the following to your section:
    BindsTo=sys-subsystem-net-devices-%i.device
    After=sys-subsystem-net-devices-%i.device
    I took these from the ifplugd service files. These are responsible for waiting after the device appears after it's rename. You need to replace %i with eno1, I think.
    Apr 22 23:13:54 nuc kernel: snd_hda_intel 0000:00:1b.0: enabling device (0000 -> 0002)
    Apr 22 23:13:54 nuc kernel: snd_hda_intel 0000:00:1b.0: irq 63 for MSI/MSI-X
    Apr 22 23:13:54 nuc kernel: input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/input/input7
    Apr 22 23:13:54 nuc kernel: input: HDA Intel PCH Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
    Apr 22 23:13:54 nuc kernel: input: HDA Intel PCH Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input8
    Could you post the output of:
    cat /proc/asound/*
    Last edited by Rexilion (2014-04-24 05:30:39)

  • [SOLVED] systemd/User, starting a Dependent service

    I am missing something simple here.  I have two services.  Once is dependent on the other.
    I got the first service to start with:
    $ cat ~/.config/systemd/user/[email protected]
    [Unit]
    Description=Syncthing - Open Source Continuous File Synchronization for %I
    Documentation=https://github.com/syncthing/syncthing/wiki
    After=network.target
    [Service]
    #User=%i
    Environment=STNORESTART=yes
    ExecStart=/usr/bin/syncthing -no-browser -logflags=0
    Restart=on-failure
    SuccessExitStatus=2 3 4
    RestartForceExitStatus=3 4
    [Install]
    #WantedBy=multi-user.target
    WantedBy=default.target
    This autostarts upon logging in with i3 and gnome.  No problem (now).
    The problem I have is with the notifier/watcher:
    $ cat ~/.config/systemd/user/[email protected]
    [Unit]
    Description=Syncthing Inotify File Watcher for %I
    Documentation=https://github.com/syncthing/syncthing-inotify/blob/master/README.md
    After=network.target [email protected]
    [email protected]
    [Service]
    #User=%i
    ExecStart=/usr/bin/syncthing-inotify -logflags=0
    SuccessExitStatus=2
    Restart=on-failure
    ProtectSystem=full
    ProtectHome=read-only
    [Install]
    #WantedBy=multi-user.target
    WantedBy=default.target
    Installed it into my namespace, like I did with the parent service:
    $ systemctl --user enable [email protected]
    On system startup/login, the service is "Dead (inactive)."
    But, I can start it manually:
    $ systemctl --user start [email protected]
    And the status of the service shows it logging and working, picking up changes, etc.
    I must be missing a configuration parameter in the service file.
    Last edited by eduncan911 (2015-05-25 14:39:38)

    mauritiusdadd wrote:
    Just a shot in the dark, but try to change the After= and Requires= lines in [email protected] to
    After=network.target syncthing@%i.service
    Requires=syncthing@%i.service
    You know how you stay up late and everything you do right seems to be wrong?
    When I ran:
    systemctl status [email protected]
    ...it showed inactive (dead) and is the reason I made this thread. 
    Changed it to this:
    systemctl --user status [email protected]
    Allowed me to see it started.  *head smack*
    And btw, I tried "syncthing@%i.service" and it worked too!  I reverted back to "[email protected]" to verify %i fixed it, but it started as well as before.  So "%i" seems agnostic and would work as well.

  • Systemd services seem to ignore "After=network.target" with NM

    Hey, I've been having some trouble with services that require the network to be up running too early in the boot sequence. I'm running NetworkManager.
    Looking at the journal shows them running before networkmanager starts the interfaces, and failing since there's no interface available yet.
    For now I've discovered that running "systemctl enable NetworkManager-wait-online.service" seems to have solved it, but is this how it is supposed to work or is something going wrong?

    MisterAnderson wrote:The service isn't exiting, it's that other services are starting whilst NetworkManager is starting, so the interfaces are initialised and named yet. After=network.target appears to only make other services wait until NetworkManager starts, not until it's finished.
    OK. I guess the problem is that NM.service is Type=dbus. so systemd doesn't wait on it to finish but only for the dbus socket to appear (?). That's why you have to insert an additional ordering point NM-online.service which delays the start of network.target. I wonder though if you can avoid that by using type-forking and removing "--no-daemon" argument...

  • [SOLVED] systemd : services failing to start on boot

    I have removed sysvinit completely as per the systemd wiki pages.
    I don't usually re-boot very often so I'm not sure exactly when the problem started.
    I only noticed this problem about 4 or 5 days ago.
    But now whenever I reboot my machine 2 services fail consistently.
    adsl.service
    colord.service
    They both start flawlessly once I can log in at a console.
    I'm using kde and in the last couple of days, while trying to fix my problem, the kdm service has failed to start a couple of times too - saying there is no X server.
    Before switching to systemd I never had any of these problems using the old rc.conf method. My DAEMONS array had the adsl service start after the network service.
    I need some help and advice to find out what is causing the problem and how to fix it.
    Last edited by bhrgunatha (2012-10-25 05:44:22)

    Thanks. That seems plausible. So I've been snooping at the journal.
    journalctl -ab
    Oct 25 17:06:13 starch systemd[1]: Started Trigger Flushing of Journal to Persistent Storage.
    Oct 25 17:06:14 starch systemd[1]: Started Recreate Volatile Files and Directories.
    Oct 25 17:06:14 starch systemd[1]: Starting System Initialization.
    Oct 25 17:06:14 starch systemd[1]: Reached target System Initialization.
    Oct 25 17:06:14 starch systemd[1]: Starting CUPS Printing Service Sockets.
    Oct 25 17:06:14 starch systemd[1]: Listening on CUPS Printing Service Sockets.
    Oct 25 17:06:14 starch systemd[1]: Starting Console System Startup Logging...
    Oct 25 17:06:14 starch systemd[1]: Starting Restore Sound Card State...
    Oct 25 17:06:14 starch systemd[1]: Starting CUPS Printer Service Spool.
    Oct 25 17:06:14 starch systemd[1]: Started CUPS Printer Service Spool.
    Oct 25 17:06:14 starch systemd[1]: Starting D-Bus System Message Bus Socket.
    Oct 25 17:06:16 starch ntpd[381]: ntpd [email protected] Tue Aug 21 15:06:24 UTC 2012 (1)
    Oct 25 17:06:16 starch ntpd[413]: proto: precision = 0.156 usec
    Oct 25 17:06:17 starch ntpd[413]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
    Oct 25 17:06:17 starch ntpd[413]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen and drop on 1 v6wildcard :: UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen normally on 2 lo 127.0.0.1 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen normally on 3 lo ::1 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: peers refreshed
    Oct 25 17:06:18 starch ntpd[413]: Listening on routing socket on fd #20 for interface updates
    Oct 25 17:06:18 starch dbus[384]: [system] Activating systemd to hand-off: service name='org.freedesktop.ColorManager' unit='colord.service'
    Oct 25 17:06:18 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.systemd1'
    Oct 25 17:07:03 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.ColorManager'
    Oct 25 17:07:03 starch dbus[384]: [system] Activating via systemd: service name='org.freedesktop.ColorManager' unit='colord.service'
    Oct 25 17:07:03 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.ColorManager'
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link down
    Oct 25 17:07:03 starch systemd[1]: Starting Manage, Install and Generate Color Profiles...
    Oct 25 17:07:03 starch systemd[1]: Started Manage, Install and Generate Color Profiles.
    Oct 25 17:07:03 starch systemd[1]: colord.service: main process exited, code=killed, status=6
    Oct 25 17:07:03 starch systemd[1]: Unit colord.service entered failed state.
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link down
    Oct 25 17:07:04 starch kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
    Oct 25 17:07:04 starch kernel: PPP generic driver version 2.4.2
    Oct 25 17:07:04 starch cupsd[380]: Unknown directive DefaultAuthType on line 26.
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link up
    Oct 25 17:07:04 starch kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    Oct 25 17:07:04 starch pppoe-start[382]: TIMED OUT
    Oct 25 17:07:04 starch kernel: NET: Registered protocol family 24
    Oct 25 17:07:04 starch pppoe-start[382]: /usr/sbin/pppoe-start: line 193: 394 Terminated $CONNECT "$@" > /dev/null 2>&1
    That seems to confirm your theory.
    eth0 link is not up when attempting to start colord and adsl
    So the $64,000 question:
    How do I defer them until eth0 is ready?
    Or how can I force the eth0 link to be up before colord or adsl try to use it?
    Last edited by bhrgunatha (2012-10-25 01:33:36)

  • [SOLVED] systemd service not starting

    Hi,
    Been using Arch for just over a week now moving from Ubuntu and loving it. Achieved so much more on Arch in this short time until this evening.
    I am trying to run a shell script at startup. I added the service file under /etc/systemd/system/myapp.service
    With the following content:
    [Unit]
    Description=Notification
    [Service]
    ExecStart=/usr/bin/myscript
    [Install]
    WantedBy=multi-user.target
    As it is I can run "systemctl restart myapp.service" and the script execute flawlessly however on reboot it does nothing and I get this error when I run systemctl status myapp.service:
    systemctl status myapp.service
    myapp.service - Notification
       Loaded: loaded (/etc/systemd/system/myapp.service; enabled)
       Active: failed (Result: exit-code) since Thu 1970-01-01 10:00:08 EST; 14s ago
      Process: 116 ExecStart=/usr/bin/myscript (code=exited, status=6)
    Other info:
    Script starts with #!/bin/sh
    Script permissions 755
    Tried adding After=network.target under unit.
    Tried Type=oneshot and forking
    O yes /var/log/messages.log | grep myapp
    Sep  6 14:25:56 alarm systemd[1]: [/etc/systemd/system/myapp.service:1] Unknown section 'unit'. Ignoring.
    Sep  6 14:25:56 alarm systemd[1]: [/etc/systemd/system/myapp.service:2] Assignment outside of section. Ignoring.
    Jan  1 01:00:11 alarm systemd[1]: myapp.service: main process exited, code=exited, status=6/NOTCONFIGURED
    Jan  1 01:00:11 alarm systemd[1]: Unit myapp.service entered failed state.
    Jan  1 01:00:11 alarm [    3.243318] systemd[1]: [/etc/systemd/system/myapp.service:1] Unknown section 'unit'. Ignoring.
    Jan  1 01:00:11 alarm [    3.243490] systemd[1]: [/etc/systemd/system/myapp.service:2] Assignment outside of section. Ignoring.
    Only thing I dont get is the date difference? I have set the timezone correctly..
    Any suggestions?
    thanks
    Last edited by blueteq (2013-09-10 10:01:11)

    Reaching the network.target does not necessarily mean that an active connection has been reached.  For example, if you use wicd or netctl-auto, it will report the stating of the service as successful after the daemon itself has started, but starting the daemon simply means that it is ready to start scanning for wireless networks and then connect.
    If you want to be absolutely sure that there is a network connection before the service starts, you should use NetworkManager.service.  That will also pull in the NetworkManager-wait-online.service which will not complete until a full connection has been reached.  At that point the startup will have reached the network-online.target.  So you should order the service after that instead.  In reality, you should order it after that anyway, no matter what netowrk connection service you use, as that is a built in target to systemd.
    Even though you have the RestartSec=35 and Restart=on-failure (which is a sane thing to do IMO), it is probably a good idea to order it After=netowrk-online.target anyway, as that will cause the service to start a bit later and at least attempt to order itself correctly.  That way it will also ensure that the service is stopped before the network is taken down as well, hopefully ensuring a clean disconnect as well.

  • Run custom systemd service before NetworkManager

    Hi, I am trying to write a systemd service that runs and completes before NetworkManager.service starts.
    I tried this:
    [Unit]
    Description=Custom service test
    Before=NetworkManager.service
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/echo Custom service test 1
    ExecStart=/usr/bin/sleep 5
    ExecStart=/usr/bin/echo Custom service test 2
    [Install]
    WantedBy=network.target
    While the custom service does start, I got this rather strange output:
    Jan 22 00:12:46 localhost echo[1166]: Custom service test 1
    Jan 22 00:12:48 localhost kernel: NVRM: GPU at 0000:02:00: GPU-(snip)
    ... some unrelated messages (acpid, kdm, etc) ...
    Jan 22 00:12:49 localhost systemd-logind[1170]: Linked /tmp/.X11-unix/X0 to /run/user/1000/X11-display.
    Jan 22 00:13:13 localhost echo[1254]: Custom service test 2
    Jan 22 00:12:50 localhost systemd[1]: Started Custom service test.
    Jan 22 00:12:50 localhost systemd[1]: Starting Network Manager...
    As you can see, while everything appears in the expected order in the log, the timestamps look very wrong. The "Custom service test 2" says "00:13:13", yet it is in the middle of "00:12:49" and "00:12:50". What gives?
    Also, notice that the first echo was at 00:12:46, but NetworkManager started at 00:12:50, which is only 4 seconds later. The "sleep" in the custom services should have made it start at 00:12:51 at the earliest. I don't understand why things are not being respected.
    The output I'd expect to see is something like this:
    Jan 22 00:12:46 localhost echo[1166]: Custom service test 1
    Jan 22 00:12:51 localhost echo[1254]: Custom service test 2
    Jan 22 00:12:51 localhost systemd[1]: Started Custom service test.
    Jan 22 00:12:51 localhost systemd[1]: Starting Network Manager...
    I have also made sure that it shows up in NetworkManager.service's After list:
    $ systemctl show -p After NetworkManager.service
    After=mycustomservice.service syslog.target systemd-journald.socket dbus.socket basic.target

    falconindy wrote:Sooooo this begs the question: what are you really trying to do?
    I'm trying to write a script that changes the interface's MAC address before NetworkManager gets a chance to take over the network interface. I'm aware that there's a page about exactly that on the wiki. I started with the systemd service from the bottom of the page, which says "Before=dhcpcd@%i.service". I changed that line to use "NetworkManager.service", and I changed the ExecStart line to "/usr/bin/macchanger -A myinterface" in order to get a random MAC address, instead of setting a fixed one like the example shows. Then I saw that macchanger's output was being mixed with NetworkManager's output in the journal, so I decided to try and write a custom service just for testing, making it start before NetworkManager, in order to see if it really was systemd's fault or if it was something macchanger-specific. Then I noticed the strange behavior described in the OP, didn't really know what to do about it, so I posted this topic. That's the story so far...
    Last edited by WindPower (2013-01-23 00:13:22)

  • How to schedule a service to run before network goes down

    Hi
    I wrote a new smf service and added it to the repository.
    When running with "stop" (when the system goes down) it sends an alert to another machine.
    My question is :
    How can I schedule that service to run just before network services go down?
    another question, how can I schedule another service to run just BEFORE system is getting down?
    Many Thanks
    --me2unix                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Dependencies appear to be really written and tested on the boot side, but they should work properly going down as well.
    My first assumption is that you'd make a dependency on the network for your service. So it should be started after the network starts, and will wait for your service to quit before trying to shut down the network.
    Now this would only apply to normal shutdowns. Also, there are mulitple services on the box that have network affects. You may need to read through several to understand their purpose and interaction to pick the correct one for your use. Probably the milestone/network will be the best choice.
    Darren

  • Systemd service to run command before stopping connman.service?

    [This is my first time creating a thread, I apoligize if there is a more suitable category]
    Hello,
    I would like to run a command at shutdown before stopping a specific service (connman). I need the command to finish before stopping connman as well.
    Is there a good way to do this? I tried searching, but it seems systemd is a bit finnicky when it comes to shutdowns.
    I'd like to achieve this without modifying connman.service (Though this would probably work for me)
    What is the best way to do this?
    Thanks,
    Jacob
    Last edited by frash23 (2014-12-21 13:59:03)

    Hi
    I'm not sure if it would work, but from logic, creating a service file for your command with an "After=" dependency to connman might do it. Assuming that systemd passes the dependencies in reverse order when shutting down...
    Plus use "ExecStop=" to make your command execute at stopping.
    You gotta try this out.
    Regards
    Edit: To test/debug you can probably simply stop connman and see if it pulls the dep (instead of shutting down completely).
    Edit2: Maybe better better use "ExecStop=" inside the connman service files. As you mentioned you copy the original service file from /usr/lib/systemd/system to /etc/systemd/system and make your modifications there. This is the correct way to modify service files.
    Or then do it with a "config" directory, analog to how it's done here: https://wiki.archlinux.org/index.php/au … al_console
    Reference 'man systemd.service':
    ExecStop=
    Commands to execute to stop the service started via ExecStart=. This argument takes
    multiple command lines, following the same scheme as described for ExecStart= above. Use of
    this setting is optional. After the commands configured in this option are run, all
    processes remaining for a service are terminated according to the KillMode= setting (see
    systemd.kill(5)). If this option is not specified, the process is terminated immediately
    when service stop is requested. Specifier and environment variable substitution is
    supported (including $MAINPID, see above).
    Evtl. make sure your links in the .wants directory reference to the correct service file. (Disable and reenable once.)
    Last edited by rebootl (2014-12-21 16:51:18)

  • How to call external processes before & after WL services start/stop

    I set up WL Admin Server and Managed Server to run as Windows services.
    I have the code to retire/re-activate in an ANT script and right now, I execute it via the command line.
    Here's my question
    I want to retire a SOA composite BEFORE my Managed Server Windows service stops and re-activate it AFTER the Window service starts up.
    Do you know how to do that? Or if you have other suggestions, please let me know
    Thanks
    I'm using 11.1.1.2

    I want to retire a SOA composite BEFORE my Managed Server Windows service stops and re-activate it AFTER the Window service starts up.
    This means you need to check for the ManagedServer is in RUNNING state right?
    in WLST you can get State of a given Managed Server with getState() method. write a WLST invoke method in ANT and try.

Maybe you are looking for