linux - Debian systemd service starts before network is ready -


os: debian jessie

i want update git repository in user folder each time system start.

i tried cron @reboot entry. cron started , in result mailed me "ssh: not resolve hostname ..."

then tried sysv init scripts. effect - same.

currently i'm trying systemd services same faulty reports.

/usr/bin/git_repo

#! /bin/sh # description:       updates local git repository latest content #cd /home/tanglor/repo su -c'cd repo;git pull' - tanglor 

/etc/systemd/system/repo.service

[unit] description = updates local git repository latest content wants=network-online.target after=network-online.target [service] type=oneshot execstart=/usr/bin/repo [install] wantedby=multi-user.target 

still no result. mean in syslog find:

sep 30 19:41:59 khlavan repo[422]: ssh: not resolve hostname bitbucket.org: name or service not known sep 30 19:41:59 khlavan repo[422]: fatal: not read remote repository. sep 30 19:41:59 khlavan repo[422]: please make sure have correct access rights sep 30 19:41:59 khlavan repo[422]: , repository exists. sep 30 19:41:59 khlavan systemd[1]: repo.service: main process exited, code=exited, status=1/failure sep 30 19:41:59 khlavan systemd[1]: failed start updates local git repository latest content. sep 30 19:41:59 khlavan systemd[1]: unit repo.service entered failed state. 

how achieve repository updates each system start?

one solution use script sleep command wait till ssh test succeed , complete. last resort, solve by-the-book.

you should check systemd documentation solution suits best, here few links may you.

many network management solutions provide way unconditionally pull in network-online.target, , upgrading effect of network.target effect of network-online.target.

if use networkmanager can enabling networkmanager-wait-online.service:

systemctl enable networkmanager-wait-online.service

if use systemd-networkd can enabling systemd-networkd-wait-online.service:

systemctl enable systemd-networkd-wait-online.service

this ensure configured network devices , have ip address assigned before boot continues. service time out after 90s. enabling service might considerably delay boot if timeout not reached. both services disabled default.

alternatively, can change service needs network up, include after=network-online.target , wants=network-online.target. (freedesktop.org, 2015)

check before=, after= selection options in man pages. these among options change order units launched systemd , select after units have launch yours.


hope if not solve problem, find way solution.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -