Welcome to the Linux Foundation Forum!

Issue with Lab 4.2

rcmillsrcmills Posts: 2
edited February 2017 in LFS201 Class Forum

I'm having an issue on 4.2 lab with what I thought would be a simple example for setting up a service with systemd

I'm running CentOS Linux release 7.3.1611 (Core) 

[[email protected] ~]$ sudo cat /etc/systemd/system/fake2.service

[Unit]

Description=fake2

After=network.target

[Service]

ExecStart=/bin/sh -c ’/bin/echo I am starting the fake2 service ; /bin/sleep 30’

ExecStop=/bin/echo I am stopping the fake2 service

[Install]

WantedBy=multi-user.target

[email protected] ~]$ sudo systemctl start fake2.service

Failed to start fake2.service: Unit is not loaded properly: Invalid argument.

See system logs and 'systemctl status fake2.service' for details.

[[email protected] ~]$ sudo systemctl -l status fake2.service

● fake2.service - fake2

   Loaded: error (Reason: Invalid argument)

   Active: failed (Result: exit-code) since Mon 2017-02-13 10:27:39 EST; 3min 42s ago

 Main PID: 4068 (code=exited, status=127)

Feb 13 10:27:39 dolphin.localdomain sh[4068]: I: ’/usr/bin/echo: No such file or directory

Feb 13 10:27:39 dolphin.localdomain systemd[1]: fake2.service: main process exited, code=exited, status=127/n/a

Feb 13 10:27:39 dolphin.localdomain systemd[1]: Failed to start fake2.

Feb 13 10:27:39 dolphin.localdomain systemd[1]: Unit fake2.service entered failed state.

Feb 13 10:27:39 dolphin.localdomain systemd[1]: fake2.service failed.

Feb 13 10:29:21 dolphin.localdomain systemd[1]: [/etc/systemd/system/fake2.service:6] Trailing garbage, ignoring.

Feb 13 10:29:21 dolphin.localdomain systemd[1]: fake2.service has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.

Feb 13 10:30:05 dolphin.localdomain systemd[1]: [/etc/systemd/system/fake2.service:6] Trailing garbage, ignoring.

Feb 13 10:30:05 dolphin.localdomain systemd[1]: fake2.service has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.

Feb 13 10:31:08 dolphin.localdomain systemd[1]: fake2.service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.

 

 

 

Comments

  • mobilemobile Posts: 15
    edited February 2017

    Hey I ran the fake2.service configuration you posted (copy and pasted from above) and got a different error. I had to replace the single quotes around the Execstart parameters surrounding the echo command.

    I made the following change:

    OLD

    [Unit]

    Description=fake2

    After=network.target

    [Service]

    ExecStart=/bin/sh -c ’/bin/echo I am starting the fake2 service ; /bin/sleep 30’

    ExecStop=/bin/echo I am stopping the fake2 service

    [Install]

    WantedBy=multi-user.target

    NEW

    [Unit]

    Description=fake2

    After=network.target

    [Service]

    ExecStart=/bin/sh -c '/bin/echo I am starting the fake2 service ; /bin/sleep 30'

    ExecStop=/bin/echo I am stopping the fake2 service

    [Install]

    WantedBy=multi-user.target

    I don't know if it will resolve your issue. I hope this helps.

  • rcmillsrcmills Posts: 2
    edited February 2017

    Thanks, that was the issue!  

  • mobilemobile Posts: 15
    edited February 2017

    Nice, no problem.

  • luisviveropenaluisviveropena Posts: 727
    edited February 2017

    Hi,

    That's weird; so, you replaced the single quotes by hand, right? Did you copy and paste the command from the pdf file? There may be something with the formatting.

  • mobilemobile Posts: 15
    edited February 2017

    Hey,

    It is weird; by hand? As opposed to using sed or something else?

    I didn't look at the pdf. I just read rcmills post then copied and pasted the configuration for their service. I assumed that rcmills hand wrote the configuration since he/she also used the name 'fake2' instead of 'fake_service' (I think thats what the pdf used).. but they could have pulled it from the pdf themself and pasted it into an editor that altered the quotes too.

    Regardless, quotes are not used anywhere else in the configuration so I also assumed they used an editor other than vi or emacs--- likely an ascii code difference between open/closed quotes and straight quotes? I didn't look into it any further. Once I ran the service I just looked at the log and changed the line; it worked.

    Whoops- streamline thinking a bit. I'll look at the pdf later and see if there are any issues on my system similar to this problem.

  • coopcoop Posts: 680

    cutting and pasting from pdf's or html often screws up single quotes fro some reason

Sign In or Register to comment.