Systemctl service timed out during start

22,307

Solution 1

Set the Type of your service script either to simple or oneshot. Depending on the behavior of the shell script that is started.

  • if the shell script runs an endless loop and does not exit, set Type to simple
  • otherwise set Type to oneshot

After you have made your changes reload the configuration with systemctl daemon-reload and start your service.

Solution 2

I also had to add (or was it because I rebooted in the end, and TimeoutSec actually doesn't make a difference?)

TimeoutSec=0

As described in https://bugzilla.redhat.com/show_bug.cgi?id=1446015#c7

The man systemd.service command on my own systems tells me infinity should be used for that. I guess both work.

Like so (Whatever GuessMainPID is, but this is how my currently working file looks like):

/etc/systemd/system/[email protected]

[Service]
Type=simple
TimeoutSec=0
GuessMainPID=false
ExecStart=/bin/bash -c "funny stuff %I"

My service was triggered from an udev rule (as in http://blog.fraggod.net/2012/06/16/proper-ish-way-to-start-long-running-systemd-service-on-udev-event-device-hotplug.html), no Idea if that makes any difference. For anyone wondering how to get the timeout log: I had to run journalctl | tail to see which kinds of errors my udev rule and service just produced.

Share:
22,307

Related videos on Youtube

Mr.D
Author by

Mr.D

Updated on September 18, 2022

Comments

  • Mr.D
    Mr.D over 1 year

    <I have created *.service and placed it in my /etc/systemd/system folder:

    [Unit]
    Description=WSO2 IoT Message broker
    
    [Service]
    Environment="JAVA_HOME=/usr/lib/jvm/java-8-oracle"
    Type=forking
    ExecStart=/home/ubuntu/wso2iot-3.1.0/bin/broker.sh
    
    [Install]
    WantedBy=multi-user.target
    

    I'm tying to run one of mudles of WSO2 IoT Server, but it does not matter.

    When I launch this bash script manually, it loads for a long time and keeps in launched mode, because it runs something like web server application which then takes specific port.

    When I launch this service like this:

    sudo systemctl start myservice.service
    

    It takes a long time and then says: Start operation timed out. Terminating.

    I need to make this service just launched forever until I stop it manually.

    What did I miss in my service config file?

  • user1655072
    user1655072 over 4 years
    can anyone explain why change Type from 'fork' to 'simple' fixed this issue?