Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Execution of the command after reboot (systemd)

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
hobit
Posts: 9
Joined: 2018-06-28 21:09

Execution of the command after reboot (systemd)

#1 Post by hobit »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Execution of the command after reboot (systemd)

#2 Post by Head_on_a_Stick »

Please post the full output of

Code: Select all

# journalctl -u tftpd-hpa
deadbang

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Execution of the command after reboot (systemd)

#3 Post by debiman »

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

hobit
Posts: 9
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

#4 Post by hobit »

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: 9
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

#5 Post by hobit »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Execution of the command after reboot (systemd)

#6 Post by Head_on_a_Stick »

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
deadbang

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Execution of the command after reboot (systemd)

#7 Post by debiman »

^ or maybe even

Code: Select all

journalctl -b | grep -i 'tftp|hpa'

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Execution of the command after reboot (systemd)

#8 Post by Head_on_a_Stick »

debiman wrote:

Code: Select all

journalctl -b | grep -i 'tftp\|hpa'
ftfy ;)
deadbang

hobit
Posts: 9
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

#9 Post by hobit »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Execution of the command after reboot (systemd)

#10 Post by Head_on_a_Stick »

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.
deadbang

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Execution of the command after reboot (systemd)

#11 Post by debiman »

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'

hobit
Posts: 9
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

#12 Post by hobit »

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.

User avatar
pylkko
Posts: 1802
Joined: 2014-11-06 19:02

Re: Execution of the command after reboot (systemd)

#13 Post by pylkko »

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

hobit
Posts: 9
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

#14 Post by hobit »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Execution of the command after reboot (systemd)

#15 Post by Head_on_a_Stick »

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.
deadbang

hobit
Posts: 9
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

#16 Post by hobit »

Head_on_a_Stick wrote: 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.
Hi, The output of command is

Code: Select all

# netstat -lnp | grep 69
udp        0      0 0.0.0.0:46796           0.0.0.0:*                           698/dhclient    
udp        0      0 0.0.0.0:68              0.0.0.0:*                           698/dhclient   
udp        0      0 172.30.11.99:69         0.0.0.0:*                           2174/in.tftpd   
udp6       0      0 :::55826                :::*                                698/dhclient    
unix  2      [ ACC ]     STREAM     LISTENING     13569    639/Xorg            @/tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     15369    583/gdm3            @/tmp/dbus-Qb6xjtVr
I was looking for it in my server, byt there is only one tftp server.
In "inetd.conf I have the line with tftp is commented:

Code: Select all

# grep -i tftp /etc/inetd.conf 
#:BOOT: TFTP service is provided primarily for booting.  Most sites
#tftp		dgram	udp4	wait	nobody /usr/sbin/tcpd /usr/sbin/in.tftpd --tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /srv/tft
I have no other ideas.

hobit
Posts: 9
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

#17 Post by hobit »

Hello everyone,

I didn't have the power for continuing of this issue.
But I have done upgrade to the Debian Stretch at last week. And it was surprice! The TFTP-HPA service works. I cleared the crontab. I deleted the attempt in systemd (restart tftp-hpa services).

The first goal was resolved by upgrade to new version of Debian. There was a bug or some bugs. And nobody know where.

I didn't resolved the second goal. I wanted to learn about systemd. But I don't understand it. And there is nobody, who had knowlidge about systemd.

Thank you averybody, who answered me and who wanted help me.

User avatar
pylkko
Posts: 1802
Joined: 2014-11-06 19:02

Re: Execution of the command after reboot (systemd)

#18 Post by pylkko »

You oversimplify the situation. You do not know that there was a bug. Software like this is being changed and new features added and old ones deprecated. Whatever change there is in the two versions of systemd could be by design. Also, upgrading the system from one release to another on Debian changes pretty much everything and the change could be in anything else.. for example some way the network stack works, or anything else. It could also be by accident that in the new system the services come up at boot in a slightly different order and the service just works. This is especially likely with systemd which starts services in parallel and not in a deterministic way like other init systems do.

Additionally, it is not surprising that there are things that no one here knows. After all there are only a few users here who are on no way officially linked with Debian development and some problems are more common and other ones rare. There is a long list of unanswered posts on this forum. Many of those questions nobody simply knows how to answer. Many of them are rare enough that other have not encountered them ever

Also you seriously confounded the situation by not giving simple and umambiguous descriptions and by adding random services that do God knows what. So it was challenging enough that many probably just gave up. Even now we don't know for sure that it started to work because of the upgrade. That's what you claim, but how do we know what other changes and solutions offered here and elsewhere on the net you did at the same time?

hobit
Posts: 9
Joined: 2018-06-28 21:09

Re: Execution of the command after reboot (systemd)

#19 Post by hobit »

pylkko wrote: Also you seriously confounded the situation by not giving simple and umambiguous descriptions and by adding random services that do God knows what. So it was challenging enough that many probably just gave up. Even now we don't know for sure that it started to work because of the upgrade. That's what you claim, but how do we know what other changes and solutions offered here and elsewhere on the net you did at the same time?
Hi pylkko, I agree with First and second paragraph. It is clear. I wanted to reduce possible bugs to minimum, that why I have chosen the Debian distribution.

But I don't understand what do you writed in the last paragraph? What is hard in my question? What did I add random services?

The question was very simple. One service "tftp" didn't run corectly after restart of server.
And I tried fix it by adding simple service. The service is very easy. I was write complete description. The service should do only "restart of tftp service", Nothing more.
What is random? What is hard for understand?
That all.

I gave all possible statements (outputs) about what happend. And described what and how I did. I didn't do anything extra. I answered to all question and sent outputs of commands. Nobody didn't ask to another explanation.

How could I have done differently? I am lama, how do I know what I should write?
When I ask something, so I am asking, because I do not know it. And I can not know how do I ask. when I do not know it.

How would you write it you?

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Execution of the command after reboot (systemd)

#20 Post by bw123 »

hobit wrote: ...
But I don't understand what do you writed in the last paragraph? What is hard in my question? What did I add random services?

The question was very simple. One service "tftp" didn't run corectly after restart of server.
And I tried fix it by adding simple service. The service is very easy. I was write complete description. The service should do only "restart of tftp service", Nothing more.
What is random? What is hard for understand?
That all.

I gave all possible statements (outputs) about what happend. And described what and how I did. I didn't do anything extra. I answered to all question and sent outputs of commands. Nobody didn't ask to another explanation.

How could I have done differently? I am lama, how do I know what I should write?
When I ask something, so I am asking, because I do not know it. And I can not know how do I ask. when I do not know it.

How would you write it you?
This response is exceptionally genuine and explains exactly how many people feel when trying to deal with similar issues with systemd. I wish I could help, and I'm sorry I have not read and tried to contribute something to the thread. We are all beginners here with systemd because it was thrust upon us all and trying to understand it is tough for people even after yrs of experience on linux.

When it works, it works. When it doesn't, get ready for months or yrs of research and waiting to find an answer.
resigned by AI ChatGPT

Post Reply