Execution of the command after reboot (systemd)

If none of the more specific forums is the right place to ask

Execution of the command after reboot (systemd)

Postby hobit » 2018-06-28 21:42

Hello.
I am struggling with the systemd setting and running the command after the boot of my computer. I know it's full on the Internet, but I did not find anything to help.
I have Debian 8.
After restarting my computer, the tftpd-hpa server does not start.

# systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
Loaded: loaded (/etc/init.d/tftpd-hpa)
Active: failed (Result: exit-code) since Thu 2018-06-28 23:42:58 CEST; 3s ago
Process: 540 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=66)

So I figured out that when I restart it right then it works:

# systemctl restart tftpd-hpa.service
# systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
Loaded: loaded (/etc/init.d/tftpd-hpa)
Active: active (running) since Thu 2018-06-28 20:54:32 CEST; 2s ago
Process: 1189 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/tftpd-hpa.service
└─1195 /usr/sbin/in.tftpd --listen --user tftp --address 172.30.11.99:69 --secure --create /srv/tftp

So I thought I would add "unit" to systemd and set it to run after tftp-hpa. But I did come across it because I just can not figure out how to set the system to make the "systemctl restart tftpd-hpa.service!" Command started after tftp-hpa.

I created the file "/etc/systemd/system/restart-tftpd-hpa.service"
----------------------------------
[Unit]
Description=Restart tftp-hpa
After=tftp-hpa.service

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart tftpd-hpa.service
SuccessExitStatus=1

[Install]
WantedBy=basic.target
----------------------------------

Updated systemd and switched on new service:
systemctl daemon-reload
systemctl start restart-tftpd-hpa.service
ssytemctl enable restart-tftpd-hpa.service

# systemctl list-dependencies
default.target
● ├─accounts-daemon.service
● ├─exim4.service
● ├─gdm.service
● ├─gdomap.service
● ├─irqbalance.service
● ├─minissdpd.service
● ├─ntp.service
● ├─openbsd-inetd.service
● ├─speech-dispatcher.service
● ├─systemd-update-utmp-runlevel.service
● ├─systemd-update-utmp-runlevel.service
● ├─tftpd-hpa.service
● └─multi-user.target
● ├─anacron.service
● ├─atd.service
● ├─cron.service
● ├─dbus.service
● ├─exim4.service
● ├─gdomap.service
● ├─hyperv-daemons.hv-fcopy-daemon.service
● ├─hyperv-daemons.hv-kvp-daemon.service
● ├─hyperv-daemons.hv-vss-daemon.service
● ├─inetd.service
● ├─irqbalance.service
● ├─minissdpd.service
● ├─ModemManager.service
● ├─NetworkManager.service
● ├─ntp.service
● ├─openbsd-inetd.service
● ├─pppd-dns.service
● ├─rc-local.service
● ├─rsyslog.service
● ├─speech-dispatcher.service
● ├─ssh.service
● ├─systemd-ask-password-wall.path
● ├─systemd-logind.service
● ├─systemd-update-utmp-runlevel.service
● ├─systemd-user-sessions.service
● ├─tftpd-hpa.service
● ├─basic.target
● │ ├─alsa-restore.service
● │ ├─alsa-state.service
● │ ├─restart-tftpd-hpa.service
● │ ├─paths.target
....

Depending on the dependency order, it is only after tftp-hpa, so right.

But after the computer reboot is still "tftp-hpa" failed.

# systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
Loaded: loaded (/etc/init.d/tftpd-hpa)
Active: failed (Result: exit-code) since Thu 2018-06-28 23:42:58 CEST; 8s ago
Process: 540 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=66)

I tried to change the parameter After where I added the network.target, and other services I tried to change in the Install section "WantedBy = multi-user.target".
He tried to add the Requires parameter i.

But it just can not be done.

Does not anyone think I'm doing wrong?
How about when I get a systemd after after some service, she should start after her, right? In dependencies it's up to her, but it does not work anyway.
I do not get it.

Hobbit.
hobit
 
Posts: 7
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

Postby Head_on_a_Stick » 2018-06-29 05:08

Please post the full output of
Code: Select all
# journalctl -u tftpd-hpa
dbruce wrote:Ubuntu forums try to be like a coffee shop in Seattle. Debian forums strive for the charm and ambience of a skinhead bar in Bacau. We intend to keep it that way.
User avatar
Head_on_a_Stick
 
Posts: 8324
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Execution of the command after reboot (systemd)

Postby debiman » 2018-06-29 15:46

are you saying you created a separate systemd service to restart a failed systemd service?
i would undo that as soon as possible.

fwiw, many network-dependent services used to fail for me because network.target is not the same as "internet is up" (which is why it then suddenly works a while later).

this has worked for me:
Code: Select all
Requires=network.target
After=dhcpcd.service
User avatar
debiman
 
Posts: 3064
Joined: 2013-03-12 07:18

Re: Execution of the command after reboot (systemd)

Postby hobit » 2018-07-01 19:39

Head_on_a_Stick wrote:Please post the full output of
Code: Select all
# journalctl -u tftpd-hpa


Hi, unfortunately, there is nothing:

# journalctl -u tftpd-hpa
-- No entries --

It is installed:
# aptitude search '~i tftpd'
i tftpd-hpa - HPA's tftp server
hobit
 
Posts: 7
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

Postby hobit » 2018-07-01 21:01

debiman wrote:are you saying you created a separate systemd service to restart a failed systemd service?
i would undo that as soon as possible.

fwiw, many network-dependent services used to fail for me because network.target is not the same as "internet is up" (which is why it then suddenly works a while later).

this has worked for me:
Code: Select all
Requires=network.target
After=dhcpcd.service


Hi
I have not tried this yet.
I will test it.
H.
hobit
 
Posts: 7
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

Postby Head_on_a_Stick » 2018-07-02 05:03

hobit wrote:
Code: Select all
# journalctl -u tftpd-hpa
-- No entries --

:?

OK, let's go old skool:
Code: Select all
# journalctl -b | grep tftpd-hpa
dbruce wrote:Ubuntu forums try to be like a coffee shop in Seattle. Debian forums strive for the charm and ambience of a skinhead bar in Bacau. We intend to keep it that way.
User avatar
Head_on_a_Stick
 
Posts: 8324
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Execution of the command after reboot (systemd)

Postby debiman » 2018-07-02 19:16

^ or maybe even
Code: Select all
journalctl -b | grep -i 'tftp|hpa'
User avatar
debiman
 
Posts: 3064
Joined: 2013-03-12 07:18

Re: Execution of the command after reboot (systemd)

Postby Head_on_a_Stick » 2018-07-02 20:09

debiman wrote:
Code: Select all
journalctl -b | grep -i 'tftp\|hpa'

ftfy ;)
dbruce wrote:Ubuntu forums try to be like a coffee shop in Seattle. Debian forums strive for the charm and ambience of a skinhead bar in Bacau. We intend to keep it that way.
User avatar
Head_on_a_Stick
 
Posts: 8324
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Execution of the command after reboot (systemd)

Postby hobit » 2018-07-03 10:01

Hi,
I am very sorry, I tried it from another server. :-( (Those black consoles look all same)
Here is the listing from the right server:
Code: Select all
# journalctl -u tftpd-hpa.service
-- Logs begin at Po 2018-07-02 16:17:10 CEST, end at Út 2018-07-03 12:33:45 CEST. --
čec 02 16:17:10 MYSERVER systemd[1]: Starting LSB: HPA's tftp server...
čec 02 16:17:10 MYSERVER systemd[1]: tftpd-hpa.service: control process exited, code=exited status=66
čec 02 16:17:10 MYSERVER systemd[1]: Failed to start LSB: HPA's tftp server.
čec 02 16:17:10 MYSERVER systemd[1]: Unit tftpd-hpa.service entered failed state.
čec 02 16:17:10 MYSERVER tftpd-hpa[485]: Starting HPA's tftpd: in.tftpd
čec 02 16:17:15 MYSERVER systemd[1]: Starting LSB: HPA's tftp server...
čec 02 16:17:15 MYSERVER tftpd-hpa[1144]: Starting HPA's tftpd: in.tftpd.
čec 02 16:17:15 MYSERVER systemd[1]: Started LSB: HPA's tftp server.

# systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
   Loaded: loaded (/etc/init.d/tftpd-hpa)
   Active: active (running) since Po 2018-07-02 16:17:15 CEST; 20h ago
  Process: 1144 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/tftpd-hpa.service
           └─1150 /usr/sbin/in.tftpd --listen --user tftp --address 172.30.11.99:69 --secure --create /srv/tftp


After boot device the tftp server doesn't works.
But then after restart the service (tftp-hpa), the tftp server works:
Code: Select all
systemctl restart tftpd-hpa.service
# netstat -an | grep 69
udp        0      0 172.30.11.99:69         0.0.0.0:*   


I am helpless.
hobit
 
Posts: 7
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

Postby Head_on_a_Stick » 2018-07-03 14:57

hobit wrote:čec 02 16:17:10 MYSERVER systemd[1]: Starting LSB: HPA's tftp server...
čec 02 16:17:10 MYSERVER systemd[1]: tftpd-hpa.service: control process exited, code=exited status=66[/code]

Are you sure you didn't miss a line between these two? The error itself is usually printed :?

For example: https://unix.stackexchange.com/question ... ter-update

You may have to trawl through the journal (plain `journalctl -b`) and look at the individual entries leading up to the failure and see if you can find any clues that could be entered into a search engine.
dbruce wrote:Ubuntu forums try to be like a coffee shop in Seattle. Debian forums strive for the charm and ambience of a skinhead bar in Bacau. We intend to keep it that way.
User avatar
Head_on_a_Stick
 
Posts: 8324
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Execution of the command after reboot (systemd)

Postby debiman » 2018-07-03 15:08

Head_on_a_Stick wrote:
debiman wrote:
Code: Select all
journalctl -b | grep -i 'tftp\|hpa'

ftfy ;)

oh i forgot the E:
Code: Select all
journalctl -b | grep -iE 'tftp|hpa'
User avatar
debiman
 
Posts: 3064
Joined: 2013-03-12 07:18

Re: Execution of the command after reboot (systemd)

Postby hobit » 2018-07-03 18:07

Hi, It is truth.
This is full finding:
Code: Select all
# journalctl -b | grep -iE 'tftp|hpa'
čec 02 16:17:10 MYSERVER CRON[480]: (root) CMD (( sleep 5 ; /bin/systemctl start tftpd-hpa.service ))
čec 02 16:17:10 MYSERVER systemd[1]: Starting LSB: HPA's tftp server...
čec 02 16:17:10 MYSERVER in.tftpd[521]: cannot resolve local IPv4 bind address: 172.30.11.99, Name or service not known
čec 02 16:17:10 MYSERVER systemd[1]: tftpd-hpa.service: control process exited, code=exited status=66
čec 02 16:17:10 MYSERVER systemd[1]: Failed to start LSB: HPA's tftp server.
čec 02 16:17:10 MYSERVER systemd[1]: Unit tftpd-hpa.service entered failed state.
čec 02 16:17:10 MYSERVER tftpd-hpa[485]: Starting HPA's tftpd: in.tftpd
čec 02 16:17:11 MYSERVER gdm-Xorg-:0[605]: (WW) evdev: Microsoft Vmbus HID-compliant Mouse: touchpads, tablets and touchscreens ignore relative axes.
čec 02 16:17:15 MYSERVER systemd[1]: Starting LSB: HPA's tftp server...
čec 02 16:17:15 MYSERVER tftpd-hpa[1144]: Starting HPA's tftpd: in.tftpd.
čec 02 16:17:15 MYSERVER systemd[1]: Started LSB: HPA's tftp server.
čec 03 12:35:14 MYSERVER systemd[1]: Started LSB: HPA's tftp server.
čec 03 12:35:23 MYSERVER systemd[1]: Stopping LSB: HPA's tftp server...
čec 03 12:35:23 MYSERVER tftpd-hpa[2268]: Stopping HPA's tftpd: in.tftpd.
čec 03 12:35:23 MYSERVER systemd[1]: Starting LSB: HPA's tftp server...
čec 03 12:35:23 MYSERVER tftpd-hpa[2272]: Starting HPA's tftpd: in.tftpd.
čec 03 12:35:23 MYSERVER systemd[1]: Started LSB: HPA's tftp server.

Why system can not resolve the ip address? It is strange.
I got an idea, maybe the order of starting services is wrong? Maybe network services is not started before "tftp-hpa.service"? But why?

I found this:
Code: Select all
# cat /run/systemd/generator.late/tftpd-hpa.service
# Automatically generated by systemd-sysv-generator

[Unit]
SourcePath=/etc/init.d/tftpd-hpa
Description=LSB: HPA's tftp server
Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target
After=local-fs.target remote-fs.target systemd-journald-dev-log.socket network-online.target
Wants=network-online.target
Conflicts=shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
SysVStartPriority=2
ExecStart=/etc/init.d/tftpd-hpa start
ExecStop=/etc/init.d/tftpd-hpa stop

The unit "network-online.target" is in line "After", therefore I think, that is right.
I do not any ideas.
hobit
 
Posts: 7
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

Postby pylkko » 2018-07-03 18:40

I woukd remove all the meta services restarting services and sleep 5 things that you have hacked in there and go to the origianl .service and edit it to run only after dhcp has run and the machine also has a ip.

see:

https://bugs.debian.org/cgi-bin/bugrepo ... bug=710747

https://forums.fogproject.org/topic/464 ... er-install

and

https://bugs.launchpad.net/ubuntu/lucid ... bug/522509
User avatar
pylkko
 
Posts: 1357
Joined: 2014-11-06 19:02

Re: Execution of the command after reboot (systemd)

Postby hobit » 2018-07-04 04:59

pylkko wrote:I woukd remove all the meta services restarting services and sleep 5 things that you have hacked in there and go to the origianl .service and edit it to run only after dhcp has run and the machine also has a ip.
see:
https://bugs.debian.org/cgi-bin/bugrepo ... bug=710747
https://forums.fogproject.org/topic/464 ... er-install
and
https://bugs.launchpad.net/ubuntu/lucid ... bug/522509

Hi, thank you. But I do not understand you well.
The server is newly installed. It is clear. And I trying install TFTP server only.
The "sleep 5" is workarround, which it works for me. It is in crontab -e. But I do not want it.
I would like using the systemd. In the systemd should be easy, but it does not work for me.
I was looking at those links, but it are old and about another system starting services. I did not find anything help for me with systemd.
hobit
 
Posts: 7
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

Postby Head_on_a_Stick » 2018-07-04 05:12

hobit wrote:
Code: Select all
čec 02 16:17:10 MYSERVER CRON[480]: (root) CMD (( sleep 5 ; /bin/systemctl start tftpd-hpa.service ))
čec 02 16:17:10 MYSERVER systemd[1]: Starting LSB: HPA's tftp server...
čec 02 16:17:10 MYSERVER in.tftpd[521]: cannot resolve local IPv4 bind address: 172.30.11.99, Name or service not known
čec 02 16:17:10 MYSERVER systemd[1]: tftpd-hpa.service: control process exited, code=exited status=66

Check the output of
Code: Select all
netstat -lnp | grep 69

as per the solution in my linked stackexchange thread, you may have a port conflict.
dbruce wrote:Ubuntu forums try to be like a coffee shop in Seattle. Debian forums strive for the charm and ambience of a skinhead bar in Bacau. We intend to keep it that way.
User avatar
Head_on_a_Stick
 
Posts: 8324
Joined: 2014-06-01 17:46
Location: /dev/chair

Next

Return to General Questions

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable