[SOLVED] systemd service dependencies

Hi,
I've just setup a new arch install, using a pure systemd setup.
I have two services, tinc and tinyproxy. In my case tinyproxy will only bind to an interface that tinc sets ups. So I have to make sure that tinyproxy startup depends on tinc. Now, I could edit the service file installed by the tinyproxy package, but I'd like to know if there is a better way to do that. With the old rc.conf sysinit I simply made sure to have the demons in the correct order and everything worked
So, is there a better way to add custom dependencies between systemd services besides manually editing the service files?
kind regards
Last edited by nomenquis (2012-09-27 08:00:56)

WorMzy wrote:Don't edit the package-provided .service file, it'll be overwritten when the package gets updated.
Yea, that's why I was afraid / didn't want to edit them :)
WorMzy wrote:Instead, copy it to /etc/systemd/system, and edit it there.
There's no other dependency mechanism as far as I know.
Ahh, didn't know that /etc/ files would override the ones provided in /usr/lib/...
I suspected there was some simple mechanism but seem to have missed that one.
Thanks a lot!
kind regards

Similar Messages

  • [SOLVED]systemd service doesn't play sound

    I have a bash script which play via 'sox' a sound file. Something like this:
    play someFile -t alsa -q
    I set up a 'systemd --user' timer which calls this script at certain time. The timer is successfully called and the corresponding service is also successfully called and exits with SUCCESS code. The problem is that sound is not heared.
    When the service is called manually from the bash with
    systemctl start mySoundTimer.service
    the sound is played OK.
    The service file is as follows:
    [Unit]
    Description= A sound timer.
    [Service]
    Type=simple
    ExecStart=/usr/bin/bash /path/to/my/script.sh
    I tried several other combinations in ExecStart:
    ExecStart=/usr/bin/bash -c /path/to/my/script.sh
    ExecStart=/usr/bin/bash "-c /path/to/my/script.sh"
    ExecStart=/usr/bin/bash -c "/path/to/my/script.sh"
    No one is working. What can be the cause of the problem?
    EDIT:
    The cause of this is a different timing behaviour of systemd timer as compared to cron which I used before. (It seemingly takes into account the time of the last run and does not run again if it is called in less than the interval between runs specified in the timer file. And I tested the timer by setting the system date to several seconds before the timer's planned times.)
    Last edited by nbd (2014-08-05 20:23:39)

    msthev wrote:$ man systemd.service
    ExecStart=
    Note that this setting does not directly support shell command
    lines. If shell command lines are to be used they need to be passed
    explicitly to a shell implementation of some kind. Example:
    ExecStart=/bin/sh -c 'dmesg | tac'
    Thanks, changing ExecStart line to
    ExecStart=/bin/bash -c '/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness'
    solved the issue. Though I can recall seeing ExecStart lines with direct shell commands.
    Raynman wrote:
    You should look at tmpfiles.d.
    https://wiki.archlinux.org/index.php/Sy … rary_files
    I'll do that, thanks!

  • [solved] systemd services not starting at boot (or at all)

    On my router, some systemd services fail to start at boot.
    The services are :
    adsl (pppoe connetction on the wan interface)
    shorewall (funny again for a router)
    logind (brings up only tty1, and not the others with a 'timeout' error)
    adsl starts fine manually after booting up
    the others don't work, I have to launch shorewall with the old sysvinit rc script (and it works)
    I really don't know, what happened to logind...
    Last edited by scar (2012-11-30 10:20:44)

    cups: avahi client failed
    adsl: timeout (ppp0 running on eth0, the service did not found eth0)
    shorewall: did not work by the systemctl command, only with the old rc script
    I'm not sure if there was an error with logind, but I've had only tty1, not all the others (I have not touched /etc/inittab)
    since this was a very old install (but up to date), I've decided to reinstall the whole thing,
    Everything works
    (But reinstalling does not solve any problem, it erases the problems...)
    Last edited by scar (2012-11-30 10:21:20)

  • [solved] systemd service files don't allow quotes

    Why is it not possible to use quotes in
    ExecStart=
    section of systemd service files?
    For example, I can't use service file like this
    [Unit]
    Description=Pacman mirrorlist update
    [Service]
    Type=oneshot
    ExecStart=wget -O /etc/pacman.d/mirrorlist.backup "https://www.archlinux.org/mirrorlist/?country=DE&country=NL&country=PL&protocol=http&ip_version=4" && cp /etc/pacman.d/mirrorlist.backup /etc/pacman.d/mirrorlist && reflector --verbose -l 50 -p http --sort rate --save /etc/pacman.d/mirrorlist
    because systemd will not run it because of presence of quotes:
    Feb 26 08:48:36 nanoBox systemd[1]: [/etc/systemd/system/reflector.service:7] Executable path is not absolute, ignoring: wget -O /etc/pacman.d/mirrorlist.backup "URL=http...
    Feb 26 08:48:36 nanoBox systemd[1]: reflector.service lacks both ExecStart= and ExecStop= setting. Refusing.
    I can remove quotes and then the service will run, but the URL parsed to the command will be cut in half, ie it will stop on the first "&" sign and only DE mirrors will be probed.
    Is there some way around it other than creating a separate executable file and calling it from the service? I don't want to multiply unnecessary files if there's way around it.
    Last edited by Lockheed (2015-02-26 09:37:25)

    Lockheed wrote:
    Raynman wrote:"from command line" is you feeding a (command) string to a shell. Your assumption is that systemd will treat whatever you put in ExecStart exactly the same as your shell would.
    Not "is" but "was". Disappearance of that assumption was precisely the reason of starting this thread.
    I had to read this a few times, but I think you mean it as follows. You assumed you could copy from the shell to the service file and it would work the same way. Then you got an error (about the abolute path) so that assumption "disappeared". So far so good. But you didn't exactly figure out what was different, you formed a new assumption and based your thread on that:
    "systemd service files don't allow quotes" (title)
    "Why is it not possible to use quotes in ExecStart= section of systemd service files"
    "because systemd will not run it because of presence of quotes:"
    Like frank604 says, quotes were never the issue (in fact, they are one of the few things with special meaning for both the shell and systemd), yet you still seem to think they were:
    Lockheed wrote wrote:The actual wrong assumption on my part was that this command would run without quotes as service. It does not.
    It is a shame you only quote the first part of my last reply and ignore the questions in the second part. You did almost the same thing with my reply before that and I suspect you also didn't read the man page I mentioned the first time. You basically give me the impression that you think you have it all figured out (even though you come here looking for help) and my follow-up questions aren't worth your time. That usually makes me "move along" pretty quickly, but I'm trying one last time, because even though "The service now works", I'd like to see that you actually understand why it didn't work before.
    The only thing you really answered was "Changing paths to absolute made no difference.", but that shouldn't be, so when you mentioned empirical evidence, I basically repeated the question asking for some of this evidence (as in exact error messages for one or more modified ExecStart lines).
    When I take your service file and give wget an absolute path, systemd happily executes wget, but then wget complains because it gets "&&" and "cp" and "--save" etc. as arguments. Those errors are what I see in systemctl status/journal, no longer anything about an absolute path. This is because "&&" has no special meaning. You can use semicolons (";") to separate commands instead (explained in the man page section on command lines) or multiple ExecStart lines like frank604 used (which is cleaner IMO).

  • [SOLVED] systemd : services failing to start on boot

    I have removed sysvinit completely as per the systemd wiki pages.
    I don't usually re-boot very often so I'm not sure exactly when the problem started.
    I only noticed this problem about 4 or 5 days ago.
    But now whenever I reboot my machine 2 services fail consistently.
    adsl.service
    colord.service
    They both start flawlessly once I can log in at a console.
    I'm using kde and in the last couple of days, while trying to fix my problem, the kdm service has failed to start a couple of times too - saying there is no X server.
    Before switching to systemd I never had any of these problems using the old rc.conf method. My DAEMONS array had the adsl service start after the network service.
    I need some help and advice to find out what is causing the problem and how to fix it.
    Last edited by bhrgunatha (2012-10-25 05:44:22)

    Thanks. That seems plausible. So I've been snooping at the journal.
    journalctl -ab
    Oct 25 17:06:13 starch systemd[1]: Started Trigger Flushing of Journal to Persistent Storage.
    Oct 25 17:06:14 starch systemd[1]: Started Recreate Volatile Files and Directories.
    Oct 25 17:06:14 starch systemd[1]: Starting System Initialization.
    Oct 25 17:06:14 starch systemd[1]: Reached target System Initialization.
    Oct 25 17:06:14 starch systemd[1]: Starting CUPS Printing Service Sockets.
    Oct 25 17:06:14 starch systemd[1]: Listening on CUPS Printing Service Sockets.
    Oct 25 17:06:14 starch systemd[1]: Starting Console System Startup Logging...
    Oct 25 17:06:14 starch systemd[1]: Starting Restore Sound Card State...
    Oct 25 17:06:14 starch systemd[1]: Starting CUPS Printer Service Spool.
    Oct 25 17:06:14 starch systemd[1]: Started CUPS Printer Service Spool.
    Oct 25 17:06:14 starch systemd[1]: Starting D-Bus System Message Bus Socket.
    Oct 25 17:06:16 starch ntpd[381]: ntpd [email protected] Tue Aug 21 15:06:24 UTC 2012 (1)
    Oct 25 17:06:16 starch ntpd[413]: proto: precision = 0.156 usec
    Oct 25 17:06:17 starch ntpd[413]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
    Oct 25 17:06:17 starch ntpd[413]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen and drop on 1 v6wildcard :: UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen normally on 2 lo 127.0.0.1 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen normally on 3 lo ::1 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: peers refreshed
    Oct 25 17:06:18 starch ntpd[413]: Listening on routing socket on fd #20 for interface updates
    Oct 25 17:06:18 starch dbus[384]: [system] Activating systemd to hand-off: service name='org.freedesktop.ColorManager' unit='colord.service'
    Oct 25 17:06:18 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.systemd1'
    Oct 25 17:07:03 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.ColorManager'
    Oct 25 17:07:03 starch dbus[384]: [system] Activating via systemd: service name='org.freedesktop.ColorManager' unit='colord.service'
    Oct 25 17:07:03 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.ColorManager'
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link down
    Oct 25 17:07:03 starch systemd[1]: Starting Manage, Install and Generate Color Profiles...
    Oct 25 17:07:03 starch systemd[1]: Started Manage, Install and Generate Color Profiles.
    Oct 25 17:07:03 starch systemd[1]: colord.service: main process exited, code=killed, status=6
    Oct 25 17:07:03 starch systemd[1]: Unit colord.service entered failed state.
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link down
    Oct 25 17:07:04 starch kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
    Oct 25 17:07:04 starch kernel: PPP generic driver version 2.4.2
    Oct 25 17:07:04 starch cupsd[380]: Unknown directive DefaultAuthType on line 26.
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link up
    Oct 25 17:07:04 starch kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    Oct 25 17:07:04 starch pppoe-start[382]: TIMED OUT
    Oct 25 17:07:04 starch kernel: NET: Registered protocol family 24
    Oct 25 17:07:04 starch pppoe-start[382]: /usr/sbin/pppoe-start: line 193: 394 Terminated $CONNECT "$@" > /dev/null 2>&1
    That seems to confirm your theory.
    eth0 link is not up when attempting to start colord and adsl
    So the $64,000 question:
    How do I defer them until eth0 is ready?
    Or how can I force the eth0 link to be up before colord or adsl try to use it?
    Last edited by bhrgunatha (2012-10-25 01:33:36)

  • [SOLVED] Systemd service files: sourcing other service files?

    Is there a way to "source" one systemd service file from another, so that the service inherits all settings from the other file? The purpose would be to override or append select fields as a quasi-patch of the other file, e.g.
    <source foo.service>
    [section]
    key=new_value
    I was sure that I had seen this somewhere, but I can't find it. Did I make this up, or is my search-fu simply weak?

    I don't know that it is actually documented at this point in time.  At least I haven't seen any.  The only reason I know about it is beacuse I subscribe to [systemd-devel].  But it was briefly touched on in the announcement when it was first introduced. 
    I know that the .include method is documented very briefly in one of the man pages, but it doesn't really go into depth about how to use it.  I do seem to recall a nice write up about it on Lennart's blog though.  But it seems as though the intent of the systemd.unit.d (what they are calling "drop-in" modifications/replacements) is intended to replace the .include way.  Though I am basing that statement off of the general attitude toward each on the mailing list, and I have seen no official word on this.
    The nice thing about using .include is that you can use systemd-delta to see the changes made using that method.  And while the systemd.unit.d changes are noted in that output, it is nothing more than simply indicating that there has been modification.  The .include stuff actually has a full "diff -u" style output.

  • [SOLVED] systemd .service file for ruby rainbows server

    I am trying to create a systemd .service file for a ruby rainbows server.
    http://rainbows.rubyforge.org/
    does anybody have experience with a forking deamon under systemd?
    Mine immediatley terminates after starting.
    Last edited by wabi (2013-01-03 11:11:02)

    This is a .service file that will work:
    [Unit]
    Description=Redmine Rainbows Rails server
    [Service]
    Type=forking
    SyslogIdentifier=redmine
    User=http
    PIDFile=/var/www/redmine/tmp/pids/rainbows.pid
    WorkingDirectory=/var/www/redmine
    ExecStart=/usr/bin/bundle exec rainbows --host 127.0.0.1 --port 8001 --env production --daemonize --config-file /var/www/redmine/config/rainbows.rb
    ExecReload=/bin/kill -HUP $MAINPID
    ExecStop=/bin/kill -QUIT $MAINPID
    [Install]
    WantedBy=multi-user.target
    Last edited by wabi (2013-01-03 11:11:38)

  • [SOLVED] systemd services load slow/fail after forcing package install

    This is more of a PSA for those coming across this issue in the future. I think people should do more of these.
    I recently had problems installing packages where pacman told me several files already existed in the filesystem. This happened when I tried to install an individual official package, not a full system upgrade, so I couldn't find any relevant posts.
    I tried to --force install the package, thereby rewriting all such files. But I noticed the next time I rebooted and logged into my system, my Cinnamon session would load extremely slowly (~2 mins) and I had several failed services.
    Symptoms of the problem included:
    - non-root partitions not mounted on boot
    - users and groups added after initial system install were gone (including sudo)
    - difficulty connecting to networks
    - trying to start/restart services resulted in a Polkit-related error and a timeout
    So after a while I found this post: https://bbs.archlinux.org/viewtopic.php?id=151915
    It suggested that the polkit-related user and group were missing and I should check my /var/log/pacman.log around the time of my force installation, which I did. This revealed pacman overwrote several files in /etc including fstab, hosts, passwd, shadow and group.
    Luckily pacman backed up all those files under the suffix *.pacorig so I by renaming the backups and rebooting I was thankfully able to return my system to normal.

    I have another example of rc.local which is mainly about configuring power saving etc etc on a netbook
    hdparm -B254 /dev/sda
    grep -q '0' /sys/class/power_supply/ADP1/online && P="powersave" || P="ondemand"
    cpupower -c all frequency-set -g "$P"
    echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
    /usr/sbin/iw dev wlan0 set power_save on
    echo '0' > '/proc/sys/kernel/nmi_watchdog'
    echo '1' > '/sys/module/snd_hda_intel/parameters/power_save'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:00.0/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:02.0/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.0/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1b.0/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.0/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.1/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.2/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.3/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.7/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.2/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.3/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:02:00.0/power/control'
    echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.1/power/control'
    /usr/sbin/ethtool -s eth0 wol d
    what is the systemd way of doing this sort of thing?
    Also where should local units be put so that they can be enabled/disabled etc. If I put them in /usr/lib/systemd/system won't they interfere with pacman?

  • [SOLVED] systemd service not starting

    Hi,
    Been using Arch for just over a week now moving from Ubuntu and loving it. Achieved so much more on Arch in this short time until this evening.
    I am trying to run a shell script at startup. I added the service file under /etc/systemd/system/myapp.service
    With the following content:
    [Unit]
    Description=Notification
    [Service]
    ExecStart=/usr/bin/myscript
    [Install]
    WantedBy=multi-user.target
    As it is I can run "systemctl restart myapp.service" and the script execute flawlessly however on reboot it does nothing and I get this error when I run systemctl status myapp.service:
    systemctl status myapp.service
    myapp.service - Notification
       Loaded: loaded (/etc/systemd/system/myapp.service; enabled)
       Active: failed (Result: exit-code) since Thu 1970-01-01 10:00:08 EST; 14s ago
      Process: 116 ExecStart=/usr/bin/myscript (code=exited, status=6)
    Other info:
    Script starts with #!/bin/sh
    Script permissions 755
    Tried adding After=network.target under unit.
    Tried Type=oneshot and forking
    O yes /var/log/messages.log | grep myapp
    Sep  6 14:25:56 alarm systemd[1]: [/etc/systemd/system/myapp.service:1] Unknown section 'unit'. Ignoring.
    Sep  6 14:25:56 alarm systemd[1]: [/etc/systemd/system/myapp.service:2] Assignment outside of section. Ignoring.
    Jan  1 01:00:11 alarm systemd[1]: myapp.service: main process exited, code=exited, status=6/NOTCONFIGURED
    Jan  1 01:00:11 alarm systemd[1]: Unit myapp.service entered failed state.
    Jan  1 01:00:11 alarm [    3.243318] systemd[1]: [/etc/systemd/system/myapp.service:1] Unknown section 'unit'. Ignoring.
    Jan  1 01:00:11 alarm [    3.243490] systemd[1]: [/etc/systemd/system/myapp.service:2] Assignment outside of section. Ignoring.
    Only thing I dont get is the date difference? I have set the timezone correctly..
    Any suggestions?
    thanks
    Last edited by blueteq (2013-09-10 10:01:11)

    Reaching the network.target does not necessarily mean that an active connection has been reached.  For example, if you use wicd or netctl-auto, it will report the stating of the service as successful after the daemon itself has started, but starting the daemon simply means that it is ready to start scanning for wireless networks and then connect.
    If you want to be absolutely sure that there is a network connection before the service starts, you should use NetworkManager.service.  That will also pull in the NetworkManager-wait-online.service which will not complete until a full connection has been reached.  At that point the startup will have reached the network-online.target.  So you should order the service after that instead.  In reality, you should order it after that anyway, no matter what netowrk connection service you use, as that is a built in target to systemd.
    Even though you have the RestartSec=35 and Restart=on-failure (which is a sane thing to do IMO), it is probably a good idea to order it After=netowrk-online.target anyway, as that will cause the service to start a bit later and at least attempt to order itself correctly.  That way it will also ensure that the service is stopped before the network is taken down as well, hopefully ensuring a clean disconnect as well.

  • Systemd service dependencies

    Assume I have a food (the "foo" daemon -- couldn't resist) that occasionally requires access to a running mysql database server.
    Can I express this somehow using systemd, so that when I say:
    > systemctl start food
    systemd will check first whether mysqld is running, and if not, start it?
    (This is not about food or mysqld, it's a question about systemd.)
    A more complex version of the same question could be bard (the bar daemon) depending on a locally running mail server, without specifying which particular one.
    Thanks,
    Johannes.

    Ah! Thank you. I never reached that man page.
    So I would have food.service Requires or Wants or BindsTo mysqld.service, and possibly also an After, so I'm sure that by the time food arrives, mysqld is ready. Great!
    Add-on: now let's assume that food requires a particular MySQL configuration setting (like, say, binary logs being on). Manually, I would do this:
    1. Edit MySQL config file, e.g. using perl -pi, so that the setting is on
    2. If MySQL is not running, start it
    3. If MySQL is running, restart it
    4. Start my actual daemon
    So the Wants and Requires and all that lets me elegantly deal with the case where MySQL isn't running yet. But what if it is, and MySQL needs to be restarted? Does systemd somehow support that use case as well, and I (again) didn't find the documentation for it? (If so, I'm very sorry and appreciate all pointers)
    Side note: Systemd does not seem to like a "systemd restart xyz" invocation from within another systemd start invocation, so I cannot write the above four steps into a food.service script. (Apparently the "inner" systemctl invocation waits for the previous one to finish before proceeding, i.e. deadlock)

  • [SOLVED] A custom systemd service doesn't execute a specific command

    I have made a custom service which should set screen brightness.
    file: /etc/systemd/system/backlight100.service
    [Unit]
    Description=Set screen brightness
    [Service]
    Type=oneshot
    ExecStart=/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness
    ExecStart=/usr/bin/beep
    [Install]
    WantedBy=multi-user.target
    (beep is there so I can know for sure that the script runs)
    The problem is, when I run "# systemctl start backlight100.service" I can hear the beep but it doesn't change the brightness. When I run "/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness" in terminal it does change the brightness... but not when I start or restart the service.
    Here's the output of systemctl status backlight100.service after starting it
    backlight100.service - Set screen brightness
    Loaded: loaded (/etc/systemd/system/backlight100.service; enabled)
    Active: inactive (dead) since Fri 2013-04-05 20:17:32 AMT; 3min 19s ago
    Process: 27698 ExecStart=/usr/bin/beep (code=exited, status=0/SUCCESS)
    Process: 27696 ExecStart=/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness (code=exited, status=0/SUCCESS)
    Apr 05 20:17:32 work systemd[1]: Starting Set screen brightness...
    Apr 05 20:17:32 work echo[27696]: 100 > /sys/class/backlight/intel_back...ss
    Apr 05 20:17:32 work systemd[1]: Started Set screen brightness.
    What am I doing wrong here? Any help appreciated.
    Last edited by axper (2013-04-05 18:35:24)

    msthev wrote:$ man systemd.service
    ExecStart=
    Note that this setting does not directly support shell command
    lines. If shell command lines are to be used they need to be passed
    explicitly to a shell implementation of some kind. Example:
    ExecStart=/bin/sh -c 'dmesg | tac'
    Thanks, changing ExecStart line to
    ExecStart=/bin/bash -c '/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness'
    solved the issue. Though I can recall seeing ExecStart lines with direct shell commands.
    Raynman wrote:
    You should look at tmpfiles.d.
    https://wiki.archlinux.org/index.php/Sy … rary_files
    I'll do that, thanks!

  • [SOLVED] Trying to write HLDS systemd service file

    Hey,
    I want to write a systemd service file for my HLDS AUR package: https://aur.archlinux.org/packages/hlds/
    My environment file looks like this:
    HLDS_USER=root
    HLDS_WORKINGDIR=/opt/hlds
    HLDS_PARAMS="-game cstrike"
    HLDS_LOGFILE=/var/log/hlds_cstrike
    The service file like this:
    After=network.target
    [Service]
    #EnvironmentFile=/etc/conf.d/hlds
    #User=${HLDS_USER}
    #WorkingDirectory=${HLDS_WORKINGDIR}
    ExecStart=/opt/hlds/hlds_run -game cstrike
    ExecStop=/bin/kill $MAINPID
    [Install]
    WantedBy=multi-user.target
    But systemd fails to start the service:
    hlds.service - Half-Life Dedicated Server
              Loaded: loaded (/usr/lib/systemd/system/hlds.service; disabled)
              Active: failed (Result: exit-code) since Thu, 2013-01-03 06:20:49 CET; 2s ago
             Process: 567 ExecStop=/bin/kill $MAINPID (code=exited, status=1/FAILURE)
             Process: 564 ExecStart=/opt/hlds/hlds_run -game cstrike (code=killed, signal=INT)
              CGroup: name=systemd:/system/hlds.service
    Jan 03 06:20:49 playground systemd[1]: Starting Half-Life Dedicated Server...
    Jan 03 06:20:49 playground systemd[1]: Started Half-Life Dedicated Server.
    Jan 03 06:20:49 playground hlds_run[564]: Invalid game type 'cstrike' sepecified.
    Jan 03 06:20:49 playground hlds_run[564]: Thu Jan  3 06:20:49 CET 2013: Server Failed
    Jan 03 06:20:49 playground kill[567]: usage: kill [ -s signal | -p ] [ -a ] pid ...
    Jan 03 06:20:49 playground kill[567]: kill -l [ signal ]
    Jan 03 06:20:49 playground systemd[1]: Unit hlds.service entered failed state
    Running
    /opt/hlds/hlds_run -game cstrike
    manually works quote well
    Someone knows how to proceed? Thanks
    Last edited by onny (2013-01-03 05:43:49)

    Solved. It didn't recognized the workingdir correctly ...

  • [Solved] systemd - To fork or not to fork when writing services

    Hello,
    Many of the programs i write services for have the option to fork or not to fork. Or are
    advertised as daemons but have the ability to not fork into the background.
    I don't understand which i should choose when writing a new service unit.
    When do you want a program to run in 'daemon-mode' and when don't you?
    Do i lose/gain anything when i make such a choice?
    Thank you.
    Last edited by captaincurrie (2015-01-01 12:32:11)

    falconindy wrote:
    anatolik wrote:
    [If you have a choice then use Type=simple for your systemd services. It is simpler and systemd will take care or proper process deamonizing, restarts and shutdowns.
    Type=forking is for historical services that cannot be run in foreground. In this case process itself will take care of its deamonizing, but systemd should know the child pid somehow so you need to provide PIDFile= option as well.
    Historical or not, Type=forking is necessary if you need to be able to order other services on the Type=forking service. Type determines the readiness protocol used by systemd. In the case of Type=simple, there is no protocol. systemd assumes that as soon as the binary is exec'd, the service is available. For Type=forking, services are considered ready after the MainPID exits (after the double fork), allowing for time to setup sockets or other resources needed to handle client requests (e.g. a database server or a web server). If you use the Type, you may find that dependent services fail to startup properly, as their dependencies aren't actually ready when systemd declares them to be.
    Thank you, that really cleared it up for me
    After your response, and re-reading the manual, it all makes sense now!

  • [Solved] Systemd user service and timer dbus error

    I have installed arch recently and added a few of my own services, for example the acpi_call commands and such. Now I want to create a systemd service that runs every 5 minutes and execute a script.
    I searched a lot and I found that I must use timers. I got the thing with the timers working, but because my script has to do with a specific user, I want it to run only every 5 minutes when i am logged in as that user.
    I tried to put the files in /etc/systemd/users, .config/local/users and all the possibilities but everytime i want to enable it, it says dbus connection refused.
    Can somebody please provide me a way to execute a systemd service every 5 minutes while I am logged in as a specific user?
    I did follow the wiki and created a dbus service and all. Everything works on that side but i can't enable my user service.
    thanks!
    Last edited by nopemopes (2015-03-25 11:10:06)

    jasonwryan wrote:
    What errors are you getting? https://bbs.archlinux.org/viewtopic.php?id=57855
    Not a Sysadmin issue, moving to NC...
    sorry, didn't mean to be incomplete.
    The error says "Failed to get D-Bus connection: Connection refused".
    I did what the wiki said: Create the dbus files, enable them and such.
    No i put my service files + timer in the places mentioned by the wiki but everytime i try to enable them, that error shows up.
    systemctl status dbus gives me all good
    dbus.service - D-Bus System Message Bus
    Loaded: loaded (/usr/lib/systemd/system/dbus.service; static; vendor preset: disabled)
    Active: active (running) since ma 2015-03-23 19:39:24 CET; 1h 18min ago
    Docs: man:dbus-daemon(1)
    Main PID: 246 (dbus-daemon)
    CGroup: /system.slice/dbus.service
    └─246 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
    mrt 23 19:39:34 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.ModemManager1' unit='...ervice'
    mrt 23 19:39:34 Jordy-Laptop dbus[246]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.ModemManager1....ectory.
    mrt 23 19:39:34 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.ModemManager1' unit='...ervice'
    mrt 23 19:39:34 Jordy-Laptop dbus[246]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.ModemManager1....ectory.
    mrt 23 19:39:39 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='...ervice'
    mrt 23 19:39:39 Jordy-Laptop dbus[246]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
    mrt 23 19:47:01 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='...ervice'
    mrt 23 19:47:01 Jordy-Laptop dbus[246]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
    mrt 23 20:51:38 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='...ervice'
    mrt 23 20:51:38 Jordy-Laptop dbus[246]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
    that's the log for dbus and these are my files:
    drive_sync.service
    [Unit]
    Description=Drive sync
    [Service]
    Type=simple
    ExecStart=drive_script.sh
    drive_sync.timer
    [Unit]
    Description=Drive sync
    [Service]
    Type=simple
    ExecStart=drive_script.sh
    these files are located in ~/.config/systemd/user
    Last edited by nopemopes (2015-03-23 20:00:55)

  • [SOLVED] Launching systemd service as non-root user

    I need to launch a systemd service as a non-root user. I've looked at this but I'm fairly confused. I don't have xorg or any desktop environment installed (this is a remote server I SSH into) but when I run
    systemctl --user status
    I get
    Failed to get D-Bus connection: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    What am I doing wrong?
    Last edited by gsingh93 (2013-12-01 07:29:29)

    I was going in the wrong direction. All I had to do was add 'User=username' and 'Group=groupname' in the [Service] section.

Maybe you are looking for

  • Enter Net Price Error in SRM System

    Dear Gurus, The user has created Purchase order in SRM Portal without flagging 'Confirmation-Related Invoice Verification' and 'Invoice Expected'.  The PO is transferred to R/3 system with '0' price and free goods indicator.  Then the user modified t

  • Reading Error Report

    Hi All, Since a few weeks/months, I have unclear restarts of my MacBook Pro [med. 2010 - 15"] and have some issues to read the report. Therefore I have gathered some error messages and hopefully you can help me out. https://dl.dropboxusercontent.com/

  • Preorder

    I preordered the whole Katy Perry album, the album got released today and it's not appearing in my music library. When I sign out of iTunes on my computer and sign back in it gives me a notification that the album is ready for download, I press downl

  • Program imp. doc. inventory lx22

    Hello guru´s I need to change the output of inventory document and I nedd to know wich is the printer program to modify by the developer. The t.code that generated this document inventory is LX22 Thanks a lot Best regars

  • JMS Queue - lookup error

    Hi All, I have created a queue 'JMSTestQueue' through the Visual Administrator/ JMS Provider. I have also created an MDB in which the ejb-j2ee-engine.xml contains a parameter as <destination-name>JMSTestQueue</destination-name> Now, when I try to dep