LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-13-2017, 04:36 PM   #1
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 912

Rep: Reputation: 42
systemd - how to properly stop dhcpcd.service?


I have stopped and disabled dhcpcd.service
Code:
systemctl stop dhcpcd.service
systemctl disable dhcpcd.service
But then dhcpcd.service went into FAILURE state. Why and how properly shutdown dhcpcd in systemd?

Code:
root@raspberrypi:/home/pi# systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled)
   Active: failed (Result: exit-code) since Sat 2017-05-13 20:44:51 UTC; 23min ago
 Main PID: 1689 (code=exited, status=1/FAILURE)

May 13 20:44:50 raspberrypi systemd[1]: Stopping dhcpcd on all interfaces...
May 13 20:44:50 raspberrypi dhcpcd[1835]: dhcpcd[1835]: sending signal TERM to pid 1689
May 13 20:44:50 raspberrypi dhcpcd[1835]: sending signal TERM to pid 1689
May 13 20:44:50 raspberrypi systemd[1]: dhcpcd.service: main process exited, code=exited, status=1/FAILURE
May 13 20:44:50 raspberrypi dhcpcd[1835]: dhcpcd[1835]: waiting for pid 1689 to exit
May 13 20:44:50 raspberrypi dhcpcd[1835]: waiting for pid 1689 to exit
May 13 20:44:51 raspberrypi systemd[1]: Stopped dhcpcd on all interfaces.
May 13 20:44:51 raspberrypi systemd[1]: Unit dhcpcd.service entered failed state.
May 13 20:51:38 raspberrypi systemd[1]: Stopped dhcpcd on all interfaces.
May 13 20:55:18 raspberrypi systemd[1]: Stopped dhcpcd on all interfaces.
 
Old 05-13-2017, 08:39 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 18,394
Blog Entries: 28

Rep: Reputation: 5801Reputation: 5801Reputation: 5801Reputation: 5801Reputation: 5801Reputation: 5801Reputation: 5801Reputation: 5801Reputation: 5801Reputation: 5801Reputation: 5801
I barely know SystemD, but this video could help: https://www.youtube.com/watch?v=IuDmg75n6FU

I watched it yesterday in my attempt to learn more about SystemD.
 
Old 05-13-2017, 09:21 PM   #3
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
The commands used should be correct. You should probably track down the error, it sounds like the service may have a problem. Maybe you can start it from the command line and see if any helpful info shows up.
 
Old 05-13-2017, 10:04 PM   #4
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 926

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
I wonder IF similar to this bug: https://bugzilla.redhat.com/show_bug.cgi?id=1356561
Can you provide version details (&distro), like in that bug? (&service config file maybe)
Note the two different pids. Any ideas from a systemd guru? (?e.g.)

Last edited by !!!; 05-13-2017 at 10:16 PM.
 
Old 05-14-2017, 03:12 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,873
Blog Entries: 12

Rep: Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032
it went to failed state already 23 minutes before you looked at the status.
maybe it's unrelated?
i'd be more worried that it stays off, i.e. other services can't restart it. maybe you have to mask it.
 
Old 05-14-2017, 04:48 PM   #6
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 912

Original Poster
Rep: Reputation: 42
Hi, thank you all fro replies.
@!!! - here are details I have collected form my system.

Code:
root@raspberrypi:/home/pi# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

root@raspberrypi:/home/pi# uname -a
Linux raspberrypi 3.16.0-4-586 #1 Debian 3.16.36-1+deb8u2 (2016-10-19) i686 GNU/Linux

root@raspberrypi:/home/pi# systemd --version
systemd 215
+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR

root@raspberrypi:/home/pi# dhcpcd --version
dhcpcd 6.7.1
Copyright (c) 2006-2015 Roy Marples

Last edited by czezz; 05-14-2017 at 04:55 PM.
 
Old 05-15-2017, 05:31 AM   #7
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 912

Original Poster
Rep: Reputation: 42
Hi, I have also checked on the latest release of 2017-04-10-raspbian-jessie-lite.img

At this stage dhcpcd is running:
Code:
root@raspberrypi:/home/pi# netstat -anop | grep -v unix
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name Timer
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      440/sshd         off (0.00/0/0)
tcp        0      0 164.48.95.90:22         164.48.95.89:54892      ESTABLISHED 2280/sshd: pi [priv keepalive (5496.12/0/0)
tcp        0      0 164.48.95.90:22         164.48.95.89:54888      ESTABLISHED 1300/sshd: pi [priv keepalive (5025.08/0/0)
udp        0      0 0.0.0.0:68              0.0.0.0:*                           2547/dhcpcd      off (0.00/0/0)
udp        0      0 0.0.0.0:46201           0.0.0.0:*                           319/avahi-daemon: r off (0.00/0/0)
udp        0      0 169.254.41.133:123      0.0.0.0:*                           462/ntpd         off (0.00/0/0)
udp        0      0 164.48.95.90:123        0.0.0.0:*                           462/ntpd         off (0.00/0/0)
udp        0      0 127.0.0.1:123           0.0.0.0:*                           462/ntpd         off (0.00/0/0)
udp        0      0 0.0.0.0:123             0.0.0.0:*                           462/ntpd         off (0.00/0/0)
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           319/avahi-daemon: r off (0.00/0/0)
Next, I stop dhcpcd via systemctl
Code:
root@raspberrypi:/home/pi# systemctl stop dhcpcd.service
I can see that dhcpcd is gone.
Code:
root@raspberrypi:/home/pi# netstat -anop | grep -v unix
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name Timer
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      440/sshd         off (0.00/0/0)
tcp        0      0 164.48.95.90:22         164.48.95.89:54892      ESTABLISHED 2280/sshd: pi [priv keepalive (5477.34/0/0)
tcp        0      0 164.48.95.90:22         164.48.95.89:54888      ESTABLISHED 1300/sshd: pi [priv keepalive (5006.30/0/0)
udp        0      0 0.0.0.0:46201           0.0.0.0:*                           319/avahi-daemon: r off (0.00/0/0)
udp        0      0 169.254.41.133:123      0.0.0.0:*                           462/ntpd         off (0.00/0/0)
udp        0      0 164.48.95.90:123        0.0.0.0:*                           462/ntpd         off (0.00/0/0)
udp        0      0 127.0.0.1:123           0.0.0.0:*                           462/ntpd         off (0.00/0/0)
udp        0      0 0.0.0.0:123             0.0.0.0:*                           462/ntpd         off (0.00/0/0)
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           319/avahi-daemon: r off (0.00/0/0)
The good thing is that daemon/process is gone.
However, it looks like systemd is not satisfied as it shows status: failed
Code:
root@raspberrypi:/home/pi# systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled)
  Drop-In: /etc/systemd/system/dhcpcd.service.d
           └─wait.conf
   Active: failed (Result: exit-code) since Sun 2017-05-14 23:01:41 UTC; 17s ago
  Process: 2553 ExecStop=/sbin/dhcpcd -x (code=exited, status=0/SUCCESS)
  Process: 2543 ExecStart=/sbin/dhcpcd -q -w (code=exited, status=0/SUCCESS)
 Main PID: 2547 (code=exited, status=1/FAILURE)

May 14 22:47:44 raspberrypi dhcpcd[2543]: forked to background, child pid 2547
May 14 22:47:44 raspberrypi systemd[1]: Started dhcpcd on all interfaces.
May 14 23:01:41 raspberrypi systemd[1]: Stopping dhcpcd on all interfaces...
May 14 23:01:41 raspberrypi dhcpcd[2553]: dhcpcd[2553]: sending signal TERM to pid 2547
May 14 23:01:41 raspberrypi dhcpcd[2553]: sending signal TERM to pid 2547
May 14 23:01:41 raspberrypi dhcpcd[2553]: waiting for pid 2547 to exit
May 14 23:01:41 raspberrypi dhcpcd[2547]: received signal TERM from PID 2553, stopping
May 14 23:01:41 raspberrypi dhcpcd[2547]: eth0: removing interface
May 14 23:01:41 raspberrypi dhcpcd[2553]: dhcpcd[2553]: waiting for pid 2547 to exit
May 14 23:01:41 raspberrypi dhcpcd[2547]: exited
May 14 23:01:41 raspberrypi systemd[1]: dhcpcd.service: main process exited, code=exited, status=1/FAILURE
May 14 23:01:41 raspberrypi systemd[1]: Stopped dhcpcd on all interfaces.
May 14 23:01:41 raspberrypi systemd[1]: Unit dhcpcd.service entered failed state.
So I decided to go one step forward and disable it:
Code:
root@raspberrypi:/home/pi# systemctl disable dhcpcd.service
Synchronizing state for dhcpcd.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d dhcpcd defaults
Executing /usr/sbin/update-rc.d dhcpcd disable
insserv: warning: current start runlevel(s) (empty) of script `dhcpcd' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `dhcpcd' overrides LSB defaults (0 1 6).
By looking at the status, I can see service is not only failed but also still enabled
Code:
root@raspberrypi:/home/pi# systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled)
  Drop-In: /etc/systemd/system/dhcpcd.service.d
           └─wait.conf
   Active: failed (Result: exit-code) since Sun 2017-05-14 23:01:41 UTC; 1min 8s ago
 Main PID: 2547 (code=exited, status=1/FAILURE)

May 14 22:47:44 raspberrypi dhcpcd[2543]: forked to background, child pid 2547
May 14 22:47:44 raspberrypi systemd[1]: Started dhcpcd on all interfaces.
May 14 23:01:41 raspberrypi systemd[1]: Stopping dhcpcd on all interfaces...
May 14 23:01:41 raspberrypi dhcpcd[2553]: dhcpcd[2553]: sending signal TERM to pid 2547
May 14 23:01:41 raspberrypi dhcpcd[2553]: sending signal TERM to pid 2547
May 14 23:01:41 raspberrypi dhcpcd[2553]: waiting for pid 2547 to exit
May 14 23:01:41 raspberrypi dhcpcd[2547]: received signal TERM from PID 2553, stopping
May 14 23:01:41 raspberrypi dhcpcd[2547]: eth0: removing interface
May 14 23:01:41 raspberrypi dhcpcd[2553]: dhcpcd[2553]: waiting for pid 2547 to exit
May 14 23:01:41 raspberrypi dhcpcd[2547]: exited
May 14 23:01:41 raspberrypi systemd[1]: dhcpcd.service: main process exited, code=exited, status=1/FAILURE
May 14 23:01:41 raspberrypi systemd[1]: Stopped dhcpcd on all interfaces.
May 14 23:01:41 raspberrypi systemd[1]: Unit dhcpcd.service entered failed state.
Now, the question is:
in systemd - is normal that once service is set to disable, it still shows its enable and failed?
That makes no sense but maybe there is some hidden logic behind it?

And by looking at other example, eg. sudo.service which is disabled by default, it seems that dhcpcd.service is not completely disabled or at least not in a clear state:
Code:
root@raspberrypi:/home/pi# systemctl status sudo.service 
● sudo.service - Provide limited super user privileges to specific users
   Loaded: loaded (/lib/systemd/system/sudo.service; disabled)
   Active: inactive (dead)

Last edited by czezz; 05-15-2017 at 05:40 AM.
 
Old 05-15-2017, 01:32 PM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,873
Blog Entries: 12

Rep: Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032
Quote:
Originally Posted by Doug G View Post
You should probably track down the error, it sounds like the service may have a problem. Maybe you can start it from the command line and see if any helpful info shows up.
Quote:
Originally Posted by ondoho View Post
i'd be more worried that it stays off, i.e. other services can't restart it. maybe you have to mask it.
some good advice there.
 
Old 05-15-2017, 01:55 PM   #9
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
Under debian I tend to use the service method. About the only thing I used systemctl for aside from multi-user.target, is ModemManager, which lacks any entries under service, and seems to exist/run for no apparently good reason.

# service --status-all
# service dhcpcd stop

Although I think it has it's own method to stop it.

# dhcpcd -x

Not sure if that's the right option, I tend towards the dhclient from the isc option(not available under arch). The dhcpcd thing is like a not so attractive overly assertive girlfriend. Honey, not right now.
 
Old 05-15-2017, 02:35 PM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,873
Blog Entries: 12

Rep: Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032Reputation: 6032
oh i keep forgetting that debian jessie is running a hybrid systemd/sysvinit system; so if the dhcpcd systemd service just passes the requests on to a sysvinit script, the failure message could be a carry-over from there.
 
Old 05-15-2017, 02:46 PM   #11
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 912

Original Poster
Rep: Reputation: 42
Thanks for replies.
I just left it in a failed state. Process seems to be killed, which means dhcpcd is gone (although systemd shows it as "enable").
Im not really sure where to look for systemd logs. Not much hints in syslog and messages.

Last edited by czezz; 05-15-2017 at 02:59 PM.
 
Old 05-15-2017, 04:03 PM   #12
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
# journalctl -a

The systemd version of logs, all logs, or whatever applies. In debian jessie the /var/log/syslog and other individual ones still exist and in human readable form, not binary whatevers.
 
Old 05-16-2017, 04:40 PM   #13
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
In Fedora, you'd use something like
Quote:
journalctl -u dhcpcd.service
to find log entries relating to your specific service.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Systemd service: AUTOSSH.service does not start at boot, how can I fix this? The_Linux_Machine Linux - Newbie 1 07-06-2016 12:00 PM
Can't access full journalctl from script via systemd service even though user is in systemd-journal group iwtbf Linux - Newbie 0 02-19-2016 02:44 PM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 09:02 AM
dhcpcd wifi: non-stop complications yocompia Linux - Wireless Networking 5 03-02-2004 12:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration