[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!

Similar Messages

  • My iphone 4s doesn't play sound out loud but the ringtone works....

    Hello,
    Thanks in advance for any advice / help you can give me.
    My iphone 4s doesn't play sound out loud, but my ringtone works. Music & videos also play with the headphones in, but if I want to watch a video or listen to music without headphones it will not make a sound, even though these things display they are playing on the screen.... does anyone have any ideas.
    I have rebooted etc but that hasn't worked
    Thanks

    Have you looked at the Ring/Silent switch on the side of the device?  It may have been moved to the Silent position.

  • [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!

  • My repaired itouch doesn't play sounds

    Today, I just got a repair for my itouch that had a ******** screen touch that didn't respond. I never got a new one for the repair. It looked "new" but it waa actually something that has been fixed from a crappy one. Great, now it doesn't play a ******* sound without the earphones. What am I supposed to do now? Get a repair AGAIN?

    Yes. get it fixed again. Just like was said in a response (by other) to you post. Please do not double post in the future.other

  • 5G iPod doesn't play sound

    I have a 5G 30GB iPod that just today stopped playing and sound. It still lets you scroll through the menus and also shows its playing a song, but you cannot hear anything. It won't play sound through the headphone jack, and I also have an Alpine CD Player with the iPod direct connect cable, and that does not work as well. I reset the iPod today and that did not do anything, and I also tried restoring it and that did not fix the problem as well. I contacted Apple support and found out it would cost $130 to fix my iPod, but the lady I talked to could not tell me what is exactly wrong with the iPod because she had never heard of this problem before. I'm basically looking to hopefully fix it myself since I dont want to shell out $130 to repair it, but probably will give in if I cannot fix this myself.

    mine does the same thing...i got it replaced once under warranty and they gave me a "new" one which began to malfunction 3 months after i got it :\ It plays the music all staticy and when i took it in they told me nothing was wrong with it...but it doesn't play and ive changed the head phones and reset it and run all the diagnostic tests...needless to say im very dissappointed with apple right now! what makes it worse is when i took it in the ipod wasn't even registered to me which means they gave me someone else's ipod which had been replaced! but since it was out of warranty when i found out it was 140 to get a new one if they found something wrong with it. so idk but this is my 2nd 5G ipod and i think its a bug that is in all of them.

  • After Effects CS6 doesn't play sound of MTS file when imported to ae.

    When I record a file on my canon hfr10 camcorder and imports to my windows computer, it plays sound when played when open with windows media player. But when i import to After Effects, it doesn't have the audio thingy near the "lock layer" button. It doesnt play audio.

    The audio is probably on the wrong tracks because your recording settings were set to channel 3&4, not 1&2. AE still only does stereo and simply doesn't see extra tracks. no chance. you need to extract the audio in an external program and import it as a separate file. Premiere should be able to handle this, but feel free to use otehr tools.
    Mylenium

  • [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 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 .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 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

  • [SOLVED] Opendias service doesn't start

    Hello,
    I've just installed the package opendias built from the AUR. But I'm facing 2 problems:
    1) I cannot start the service using systemctl. The binary starts fine by running it directly.
    2) I also have issues finding the scanner that works properly using SANE.
    My user was added to the opendias group. Any idea on how to solve this? Thank you in advance.
    [paulo@SonyVaio ~]$ systemctl status opendias.service -l
    ● opendias.service - OpenDIAS (Document Imaging Archive System)
    Loaded: loaded (/usr/lib/systemd/system/opendias.service; enabled)
    Active: failed (Result: start-limit) since Sáb 2014-05-10 23:24:05 WEST; 1min 32s ago
    Process: 3005 ExecStart=/usr/bin/opendias (code=exited, status=1/FAILURE)
    Mai 10 23:24:05 SonyVaio systemd[1]: Failed to start OpenDIAS (Document Imaging Archive System).
    Mai 10 23:24:05 SonyVaio systemd[1]: Unit opendias.service entered failed state.
    Mai 10 23:24:05 SonyVaio systemd[1]: opendias.service holdoff time over, scheduling restart.
    Mai 10 23:24:05 SonyVaio systemd[1]: Stopping OpenDIAS (Document Imaging Archive System)...
    Mai 10 23:24:05 SonyVaio systemd[1]: Starting OpenDIAS (Document Imaging Archive System)...
    Mai 10 23:24:05 SonyVaio systemd[1]: opendias.service start request repeated too quickly, refusing to start.
    Mai 10 23:24:05 SonyVaio systemd[1]: Failed to start OpenDIAS (Document Imaging Archive System).
    Mai 10 23:24:05 SonyVaio systemd[1]: Unit opendias.service entered failed state.
    [paulo@SonyVaio ~]$ whereis opendias
    opendias: /usr/bin/opendias /usr/lib/opendias /etc/opendias /usr/etc/opendias /usr/share/opendias
    Last edited by BullGates (2014-05-11 00:11:19)

    Update: service start solved. the database and the log files were set as root, after fixing it to the user opendias it works fine.
    Regarding 2) when I use scanimage -L, the output is:
    [paulo@SonyVaio ~]$ scanimage -L
    device `epkowa:net:192.168.1.67:1865' is a Epson Stylus NX330/SX430W/TX430W/ME OFFICE 570W Series flatbed scanner
    but if I issue a command sane-find-scanner it doesn't seem to find the scanner. Seems like a problem from opendias

  • My iphone doesn´t play sound on logitech pure-fi anywhere

    Hi,
    my iphone 4 recently quit playing music over the logitec Pure-Fi Anywhere Speakers. It did before but it doesn´t anymore. My husbands iphone still cooperates so it can´t be the speakers who are broken. My iphone still plays the sound on it´s own speakers but it won´t play them loud on the logitech speakers. I had this problem before but after a while it worked again ... is it a button I need to press or something else I am missing?
    Thanks!

    Reset your iPhone while it is connected to the PureFi: Hold down the home and sleep buttons, ignore the red Off slider, wait for the Apple logo and let go.

  • My BlackBerry doesn't play sounds?

    Hi, i've had my BlackBerry Curve 8520 for a while, and i've had no problems with it until today. I would change my sound profile to 'Normal' and it wouldn't play the sound whenever I got a message. I went into Edit Profiles > Normal > Messages > SMS > and I would go all the way to the bottom and press Try It, but the sound wouldn't play. Please help me! Thanks !
    Solved!
    Go to Solution.

    Hello,
    I think you can try two things : the soft reboot, and if it does not work, the hard reboot. Don't worry, you can't lose data with these two reboots.
    Soft reboot :
    1) Hit the three following keys at the same time :
    - Alt
    - Right Shift
    - Delete
    2) wait 2 minutes for the Blackberry to wake up.
    Hard reboot :
    1) your Blackberry device is on
    2) remove the battery and wait for a minute
    3) Put the battery back
    4) wait 5 minutes for the device to wake up.
    Please tell us if it works for you.
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

Maybe you are looking for