Mythtv with systemd problems [SOLVED]

Anyone using mythtv with systemd?  I am using the following to get systemd to start mythbackend but it attempts to start before mysqld is fully ready and thus fails:
$ cat /etc/systemd/system/mythbackend.service
[Unit]
Description=MythTV backend service
After=network.target mysqld.service
[Service]
Type=simple
Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
Environment=HOME=/usr/share/mythtv
User=mythtv
ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
[Install]
WantedBy=multi-user.target
Here is the status output... any advice?
# systemctl status mythbackend.service
mythbackend.service - MythTV backend service
Loaded: loaded (/etc/systemd/system/mythbackend.service; enabled)
Active: failed (Result: exit-code) since Thu, 10 May 2012 11:59:57 -0400; 2min 40s ago
Process: 415 ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv/mythbackend.log (code=exited, status=130)
CGroup: name=systemd:/system/mythbackend.service
May 10 11:59:54 mars mythbackend[415]: 2012-05-10 11:59:54.273466 E Driver error was [1/2002]:
May 10 11:59:54 mars mythbackend[415]: QMYSQL: Unable to connect
May 10 11:59:54 mars mythbackend[415]: Database error was:
May 10 11:59:54 mars mythbackend[415]: Can't connect to local MySQL server through socket '/var/ru... (2)
May 10 11:59:56 mars mythbackend[415]: No UPnP backends found
May 10 11:59:56 mars mythbackend[415]: Would you like to configure the database connection now? [no]
May 10 11:59:56 mars mythbackend[415]: [console is not interactive, using default 'no']
May 10 11:59:56 mars mythbackend[415]: 2012-05-10 11:59:56.526065 I UPnPautoconf() - No UPnP back...ound
May 10 11:59:56 mars mythbackend[415]: 2012-05-10 11:59:56.526080 A No UPnP backends found
May 10 11:59:56 mars mythbackend[415]: 2012-05-10 11:59:56.526190 C Failed to init MythContext.
Last edited by graysky (2012-05-11 20:17:34)

Cool, 65kid.  Back on topic: http://rpm.pbone.net/index.php3/stat/4/ … 4.rpm.html
$ cat ./usr/libexec/mysqld-wait-ready
#!/bin/sh
# This script waits for mysqld to be ready to accept connections
# (which can be many seconds or even minutes after launch, if there's
# a lot of crash-recovery work to do).
# Running this as ExecStartPost is useful so that services declared as
# "After mysqld" won't be started until the database is really ready.
# Service file passes us the daemon's PID
daemon_pid="$1"
# extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT
# result is returned in $result
# We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match.
get_mysql_option(){
result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
fi
# Defaults here had better match what mysqld_safe will default to
get_mysql_option mysqld datadir "/var/lib/mysql"
datadir="$result"
get_mysql_option mysqld socket "$datadir/mysql.sock"
socketfile="$result"
# Wait for the server to come up or for the mysqld process to disappear
ret=0
while /bin/true; do
RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
mret=$?
if [ $mret -eq 0 ]; then
break
fi
# exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
# anything else suggests a configuration error
if [ $mret -ne 1 -a $mret -ne 11 ]; then
ret=1
break
fi
# "Access denied" also means the server is alive
echo "$RESPONSE" | grep -q "Access denied for user" && break
# Check process still exists
if ! /bin/kill -0 $daemon_pid 2>/dev/null; then
ret=1
break
fi
sleep 1
done
WTF: /usr/bin/my_print_defaults
Here is the Arch rc.d script... how to adapt this for systemd?
stat_busy "Starting MySQL Server"
[ ! -d /var/run/mysqld ] && install -d -g mysql -o mysql /var/run/mysqld &>/dev/null
if [ -z "$(getPID)" ]; then
/usr/bin/mysqld_safe --user=mysql &>/dev/null &
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
timeo=30
while [ $timeo -gt 0 ]; do
response=`/usr/bin/mysqladmin -uUNKNOWN_USER ping 2>&1` && break
echo "$response" | grep -q "mysqld is alive" && break
sleep 1
let timeo=${timeo}-1
done
if [ $timeo -eq 0 ]; then
stat_fail
exit 1
else
echo $(getPID) > /var/run/mysqld/mysqld.pid
add_daemon mysqld
stat_done
fi
fi
else
stat_fail
exit 1
fi
Last edited by graysky (2012-05-10 19:06:04)

Similar Messages

  • Help with systemd problems/reply to closed thread

    @Everyone; as the previopus topic was closed, I am opening a new one here, partly to reply to some things that was said to me in the previous thread/topic (and I do not like to leave people hanging), but mainly to try and get some help with my systemd config (that I was not able to find help with in the wiki or manpages).
    @czubek; eww, that sounds rather similiar to some other operating systems I've heard of (not just, but obviously including, windows)... For me, subjectively, that is not very attractive, as being able to have a single application do a single thing, and then mixing and matching as I personally see fit is a great thing.
    @tomegun: I can indeed see your point, but if I made direct quotes on all the things I reply too, my posts would reach biblical proportions.
    Mmm-hmm, I do indeed know of "the Arch Way"; however, the system that you expose can be of varying complexity as well, and I found that the system that was presented to me by way of Sysvinit/initscripts was a way simpler system than that presented to me by systemd.
    Indeed, and I do like that; I enjoy knowing how my system works and learning more about it; however, the truth is that reading manpages and the wiki isn't always enough. And I use the numbers instead of letters in certain places as a jest, please, do not get offended by that; if you have to, get offended by my opinions.
    Ah, I have now scanned the wiki, the manpages, and have already faced problems. While part of me is saddened by this fact (as I was hoping for a smooth transition to systemd), part of me is glad that I can at least prove that everything isn't quite as simple as some people would make it out to be. More on this later in this post, as I do need help with the problems I have faced.
    And I wouldn't say that the new and old way are equally trivial, as I immediatley faced problems with "the new way". More on this later.
    Ok, I find that if the debate is polarized, then there is nothing wrong with describing it as such. I spell what I see.
    Oh my... Ignored as a matter of principle? I would say that that is an excellent way to stagnate; by that logic, moviemakers, gamemakers etcetera should ignore any and all criticism they recieve, as the critics are not contributing.... Wouldn't that lead to a complete halt in development? Isn't criticism (so long as it is constructive, obviously) a key component of (media/software) evolution?
    Ah, I see, then I  misunderstood the current state of the install media
    "Some adjustements"... Well, I guess we'll have to see how that goes, then. Hopefully it'll be smooth.
    @Everyone; Awebb possesses stunning accuracy as far as his observations go.
    @zb3; My point exactly.
    @tomegun; I believe you to be wrong; complaining (but not whining) is the first step towards improvement, as I think that I and zb3 has shown.
    Further, your last point (where you talk about "deep understanding of Y" and whatnot) is basically saying that only devs and programmers can contribute, so zb3's observation would be correct.
    Also, making suggestions is part of constructive criticism; you can do that even if you can't code, e.g. by saying "X works badly because it makes Y crash; couldn't we replace X with something akin to Z?". This is a valid point even if you have no intricate understanding of X, Y or Z, and if it is impossible to replace X for one reason or the other, it's not hard to reply with "Replacing X is impossible because of reason Q", and then see if someone can solve reason Q etcetera.
    zb3's example is obviously helping; for one, it would allow people to know taht they can't boot with systemd in certain cases, or that installing/runing systemd can break their system. I would consider that rather important information.
    @Everyone; Now then, to see if I can (or rather, if I can get help to) shed some light on some problems I've been having.
    My transition to systemd went pretty smooth (besides the fact that I couldn't use 'systemctl' to set anything, and neither duckduckgo nor any posts in the forums could help me (the error I continously got was "Failed to issue method call: Launch helper exited with unknown return code 1") and that there are no manpages/tips on how to configure the files for "localtime" and "adjtime", which would've been good considering some syntax have changed) to about halfway through, to the point where I was supposed to start using systemd for my daemons.
    Now then, to the main problem; first, I tried running
    "systemctl enable syslog-ng.service"
    and got the following message;
    "ln -s '/usr/lib/systemd/system/syslog-ng.service' '/etc/systemd/system/syslog.service'
    ln -s '/usr/lib/systemd/system/syslog-ng.service' '/etc/systemd/system/multi-user.target.wants/syslog-ng.service'"
    Since it doesn't exclusively say that something went wrong (at least as far as I can understand), I pondered the message a bit, but moved on to try and start dbus by issuing
    "systemctl enable dbus.service",
    to which I got the reply
    "The unit files have no [Install] section. They are not meant to be enabled using systemctl."
    This I can only assume is an error message of some sort, especially seeing as it says "not meant to be enabled using systemctl", but the wiki rather explicitly states that that is what I am supposed to do.
    I dare not move on (or attempt to start other daemons) without further advice, as I fear I might break my system. Any ideas as to how to solve this would be greatly appreciated.

    tcmdvm wrote:
    The message;
    "ln -s '/usr/lib/systemd/system/syslog-ng.service' '/etc/systemd/system/syslog.service'
    ln -s '/usr/lib/systemd/system/syslog-ng.service' '/etc/systemd/system/multi-user.target.wants/syslog-ng.service'"
    indicates that running "systemctl enable syslog.service" is now enabled.
    If you try running sytemtctl enable <whatever>.service and get
    "The unit files have no [Install] section. They are not meant to be enabled using systemctl." means there is no <whatever>.service file available to enable.
    The dbus.service as far as I know is already enabled when installing systemd and doesn't require any action.
    Ah, right, systemd is chatty (I'm of the old skool; if nothing is/goes wrong, a program should keep quiet).
    Oh ok, then I should dare more on.
    ZekeSulastin wrote:To be a bit more precise, it means the service is there but it's only used as a dependency for something else; the [Install] section of the file is what tells systemctl where to link it and such.  Also, where exactly in the wiki were you told explicitly to 'systemctl enable dbus.service'?  I can easily point you to the sections in both installation guides that tell you how to set things like /etc/localtime et. al (also `man 7 archlinux`), but not the one that said to manually enable dbus.
    Ah, I see; and well, I was told right here, going from the top, to "Enable Daemons formerly listed in rc.conf [...] For a translation of the daemons from /etc/rc.conf to systemd services, see: List of Daemons and Services.", and, using the list, dbus is mentioned there, as you can see. Since I started from the top, I did not know that you didn't need to enable that service. Perhaps it could be added to the descriptions of the relevant services in the Wiki which ones are autostarted?
    ZekeSulastin wrote:Lastly, I don't think trying to continue conversations from a closed thread is a very good idea, let alone doing it in a giant undivided wall of text that makes it quite difficult to pick out much any single topic.
    Meh, I directly refer to the relevant people, they can easily see their own old posts in the previous thread, etcetera... I think te ones who have something to say will be able to find my replies to their previous statements (or so I hope). For now, as everyone can see, I quote stuff (but man might I make some huge posts if I ever post again in the future, if I quote what I reply to).
    fsckd wrote:This is not really a technical support subforum. Moving from Arch Discussion to Newbie Corner.
    Ah ok, thanks (or perhaps a cautious thanks? Moving it to "newbie corner" might, after all, be a subtle insult...).
    tomegun wrote:It is not really possible to follow your message as you don't quote what you are replying to. Moreover, as the thread was closed I think that means we should stop the discussion ;-)
    Hmm, I think it means cop-out for lack or proper arguments/responses... But ok, I'll let it slide, for now (mainly as I can't do much else).
    tomegun wrote:You are not meant to enable dbus.service as it is enabled unconditionally. To check the enabled/disabled state of your services try "systemctl list-unit-files". "static" means that you are not supposed to enabled/disable it.
    Ah ok, thank you. Now, having abandoned all hope, I'll start configuring again and see how it goes... May the void protect me. If I die, grieve not for me, but remember me in the fight against hard-to-configure applications.
    (edit/addon)
    Actually, what am I supposed to do with "hwclock"? the List of Daemons only says that I shouldn't run that in tandem with ntpd, but I'm not running ntpd, so... How do I get hwclock with systemd?
    Edited for additional question.
    Last edited by incassum (2012-11-07 08:44:42)

  • Stuck with grub problem (SOLVED)

    Today i tried to upgrade my Arch Linux, it downloaded everything that should be downloaded, it was installing upgrades but at the installing grub it stucks as like this
    "Copying /boot/grub/grub.cfg.pacsave to /boot/grub/grub.cfg"
    I've waited it for about 15 minutes, it didn't move on. So i did ctrl+z to break. Then i tried to update again. But it gives an error which is:
    error: failed to commit transaction (conflicting files)
    python: /usr/bin/2to3 exists in filesystem
    Error occured, no packages were upgraded.
    Please help me guys!
    Last edited by bilgee0629 (2011-03-21 10:36:28)

    Problem solved by moving 2to3 to other directory.

  • Premier pro play back screen goes black a freezes every 15 minute . This is my second mac pro with identical problems.

    Premier pro play back screen goes black a freezes every 15 minute . This is my second mac pro with identical problems.

    SOLVED!!!!!
    SO I did some more digging around and read ATI cards seem to overheat easily.  I knew the fan was working, but after closer inspection I realised there was ALOT of built up dust on the card and clogging the fan and airflow.  Blew it out with alot of compressed air, stuck it back in the Mac and BAM...no black screens.  I tested it by streaming 6 video sources...doing 2 screen captures at once as well as watching a HD movie in fullscreen.  Did all this for 30 minutes and no crashes.  I also downloaded an app to monitor the temps inside the computer and the expansion bay stays at 41 degrees.  No clue what it was before but obviously it was hotter than that.  So my problem is solved!  Funny that 10.7.5 made the card work harder.  I wonder if its off loading some CPU stuff to the GPU for processing more than 10.7.4 so its just working a bit harder and so it heats up faster....

  • [SOLVED] Problems with systemd's journal when using syslog() in C

    Hi,
    I have a problem with journalctl and syslog output within a C program:
    When I use journalctl in follow mode:
      $ journalctl -f
    and I run the folowing program in another terminal
    #include <stdio.h>
    #include <syslog.h>
    int main()
    FILE *pf;
    int i;
    /* logging made in file /var/log/syslog */
    openlog("martins",LOG_CONS,LOG_USER);
    pf = fopen("not_here","r");
    if (!pf)
    syslog(LOG_ERR | LOG_USER,"oops -- %m\n");
    return 0;
    no syslog error message appears in the journal.
    But, when I modify the programm by adding a 'sleep(1);' right before 'return 0;'
    there is a correct error message shown in the journal.
    Is this a bug in systemd? Or do I understand something wrong with systemd's journal?
    I'm actually running
    linux-3.10-12-1-lts
    systemd 207
    with a 32Bit installation
    Thanks for any hints,
    Martin
    Last edited by thesofty (2013-10-01 19:10:13)

    Now, I understand what's going on:
    1) There is an known issue about a race condition in journald when the logging process exits. In this case the message isn't assigned to the user whose process generated the message.
    2) Apparently the group of the journal files have been changed from 'adm' to 'systemd-journal' in Arch Linux around April 2013.
    But still I only have been member of 'adm' as described in the journal tutorial on http://0pointer.de/blog/projects/journalctl.html. So I  can only see syslog messages, which are correctly assigned to my own user account. The messages with the race condition, as mentioned above, have been invisible to me.
    After joining to the new right group again:
      $ sudo usermod -d G  martin systemd-journal
    I also see the syslog messaes just before exiting the process again :-).

  • Getting sasc-ng to work properly with systemd service files [SOLVED]

    This thread is intended for getting the following AUR packages to work with each other with systemd service scripts:
    https://aur.archlinux.org/packages/open-sasc-ng-dkms/
    https://aur.archlinux.org/packages/open-sasc-ng/
    https://aur.archlinux.org/packages/oscam-svn/   (this is a related package as it must properly execute prior to sasc-ng)
    So my server is now on a fresh Arch install with systemd. All is well (& very fast) except I cannot get sasc-ng to function with systemd service init files. Prior to systemd the system worked fine with the rc initscripts & was very stable with the following setup:
    rc.local
    /etc/rc.d/oscam start
    sleep 15
    /etc/rc.d/sasc-ng start
    sleep 4
    /etc/rc.d/mythbackend start
    /etc/conf.d/sasc-ng.conf
    SASCNG_ARGS="-j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget"
    DVBLOOPBACK_ARGS="num_adapters=3"
    LOGDIR="/home/mythtv/logs/"
    CAMDIR="/etc/camdir"
    /etc/camdir/cardclient.conf
    camd35:localhost:15050:1/0000/0000:mythtv:mythtv
    I'll leave out the oscam stuff as that loads fine and doesn't appear to be a part of the problem
    I've tried this with the systemd service file that comes with the open-sasc-ng-dkms package and when it was not sucessful I tried a bunch of variants including using "Type=simple" ect. "Type=Forked" seems to be only option that actually tries to start the processes. I also "hardcoded" the service files for the 2 sasc-ng components to find a few issues with the EnvironmentFile variables. The log variable has been removed for now as this seems to cause a fatal error but the rest of the variables load fine now. I also tested spliting up the DVB loopback module from the sasc-ng binary but this also gives similar results as the following script stands now. Running them manually with systemctl start commands doesn't make a difference but that is not surprising. The service file I'm fiddling with now which I feel has the best potential become working is:
    sasc-ng.service
    [Unit]
    Description=Sasc-ng
    After=oscam.service
    [Service]
    Type=forking
    EnvironmentFile=/etc/conf.d/sasc-ng
    ExecStartPre=/sbin/modprobe dvbloopback $DVBLOOPBACK_ARGS
    TimeoutSec=2
    ExecStart=/usr/sbin/sasc-ng -D $SASCNG_ARGS --cam-dir=$CAMDIR
    TimeoutSec=4
    [Install]
    WantedBy=multi-user.target
    Mythbackend always runs fine (even without DTV via sasc-ng) with the following mythbackend.service:
    [Unit]
    Description=MythTV_backend
    After=sasc-ng.service
    [Service]
    Type=simple
    Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
    Environment=HOME=/usr/share/mythtv
    User=mythtv
    ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
    [Install]
    WantedBy=multi-user.target
    oscam.service taken mostly from AUR package also seems fine. I added the TimeoutSec=15 to give time for oscam to load the SC and client protocol before moving on or else sasc-ng fails
    Unit]
    Description=An Open Source Conditional Access Module software
    After=network.target
    [Service]
    Type=forking
    EnvironmentFile=/etc/conf.d/oscam
    ExecStart=/usr/bin/oscam $OSCAM_ARGS
    TimeoutSec=15
    [Install]
    WantedBy=multi-user.target
    Below is the output of the systemctl status commands. Despite the noise in the sasc-ng binary status, it is the loopback module that is " inactive (dead)" and there are no virtual DVB devices being created:
    [mythtv@server ~]$ sudo systemctl status oscam.service
    oscam.service - An Open Source Conditional Access Module software
    Loaded: loaded (/usr/lib/systemd/system/oscam.service; enabled)
    Active: active (running) since Tue, 2012-11-27 21:10:17 CET; 1min 7s ago
    Process: 338 ExecStart=/usr/bin/oscam $OSCAM_ARGS (code=exited, status=0/SUCCESS)
    Main PID: 377 (oscam)
    CGroup: name=systemd:/system/oscam.service
    ├ 377 /usr/bin/oscam -b -c /etc/oscam
    └ 378 /usr/bin/oscam -b -c /etc/oscam
    Nov 27 21:10:17 server systemd[1]: Started An Open Source Conditional Acces...e.
    [mythtv@server ~]$ sudo systemctl status loopback.service
    loopback.service - Sasc-ng DVB Loopback Module
    Loaded: loaded (/etc/systemd/system/loopback.service; enabled)
    Active: inactive (dead) since Tue, 2012-11-27 21:10:28 CET; 1min 27s ago
    Process: 907 ExecStart=/sbin/modprobe dvbloopback num_adapters=3 (code=exited, status=0/SUCCESS)
    CGroup: name=systemd:/system/loopback.service
    Nov 27 21:10:28 server systemd[1]: Started Sasc-ng DVB Loopback Module.
    [mythtv@server ~]$ sudo systemctl status sasc-ng.service
    sasc-ng.service - Sasc-ng
    Loaded: loaded (/etc/systemd/system/sasc-ng.service; enabled)
    Active: failed (Result: exit-code) since Tue, 2012-11-27 21:10:47 CET; 1min 45s ago
    Process: 913 ExecStart=/usr/sbin/sasc-ng -D -j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget --cam-dir=/etc/camdir -l /home/mythtv/logs/sasc-ng.log (code=exited, status=0/SUCCESS)
    Main PID: 921 (code=exited, status=255)
    CGroup: name=systemd:/system/sasc-ng.service
    Nov 27 21:10:39 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.info] loading cardclien...nf
    Nov 27 21:10:42 server sasc-ng[921]: [1062] Netwatcher thread started (pid=...6)
    Nov 27 21:10:42 server sasc-ng[921]: [921] [general.error] no keys loaded f...m!
    Nov 27 21:10:46 server sasc-ng[921]: [1098] SC housekeeper thread started (...2)
    Nov 27 21:10:47 server sasc-ng[921]: [1062] Netwatcher thread ended (pid=92...6)
    Nov 27 21:10:47 server systemd[1]: sasc-ng.service: main process exited, co.../a
    Nov 27 21:10:47 server systemd[1]: Unit sasc-ng.service entered failed state
    [mythtv@server ~]$ sudo systemctl status sasc-ng.service
    sasc-ng.service - Sasc-ng
    Loaded: loaded (/etc/systemd/system/sasc-ng.service; enabled)
    Active: failed (Result: exit-code) since Tue, 2012-11-27 21:10:47 CET; 2min 9s ago
    Process: 913 ExecStart=/usr/sbin/sasc-ng -D -j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget --cam-dir=/etc/camdir -l /home/mythtv/logs/sasc-ng.log (code=exited, status=0/SUCCESS)
    Main PID: 921 (code=exited, status=255)
    CGroup: name=systemd:/system/sasc-ng.service
    Nov 27 21:10:39 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/smartcard.conf: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/cardslot.conf: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/SoftCam.Key: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.info] loading cardclient config from /etc/camdir/cardclient.conf
    Nov 27 21:10:42 server sasc-ng[921]: [1062] Netwatcher thread started (pid=921, tid=140074379712256)
    Nov 27 21:10:42 server sasc-ng[921]: [921] [general.error] no keys loaded for softcam!
    Nov 27 21:10:46 server sasc-ng[921]: [1098] SC housekeeper thread started (pid=921, tid=140074371319552)
    Nov 27 21:10:47 server sasc-ng[921]: [1062] Netwatcher thread ended (pid=921, tid=140074379712256)
    Nov 27 21:10:47 server systemd[1]: sasc-ng.service: main process exited, code=exited, status=255/n/a
    Nov 27 21:10:47 server systemd[1]: Unit sasc-ng.service entered failed state
    [mythtv@server ~]$
    Any ideas?
    Last edited by wdirksen (2012-12-10 19:54:43)

    After some head scratching it seems to be all good now. Considering there have been no replies to this I've come to wonder if I might be the only one with this issue. I could get it working somewhat using service files but never ideal, ex. sasc-ng only using a few of the entitlements from oscam because it started too quick etc. Anyway this might help a few and I'm hoping the linux savvy who find what I'm writing here painfully newbie like or flawed will reply and educate me a bit if what's provided here needs some sharpening up:
    1) Systemd was confusing the sasc-ng binary shorthand arguments with Linux init arguments and a few were misinterpreted if they were not nested into the environment specifiers. So the -l (log) was causing problems and -b (buffer) wasn't loading. To be safe I'm using only the sasc-ng longhand specifiers from now on (two "--" and more verbose) so that they can never be confused even if safely nested in an environment parameter. That means that /etc/conf.d/sasc-ng will also need to be changed to reflect this. I also decided to simplify the LOGFILE parameter to include the whole argument syntax.
    2) Oscam.service needs to be initiated with oneshot and RemainAfterExit=yes to make sure the delay (15 seconds in my config) gets counted out before sasc-ng initiates.
    [EDIT 12/12/2012: Initially I had a second TimeoutSec=2 after ExecStart in sasc-ng.service but this had no function. Turns out that it almost always does work without this delay but not always with my setup. Adding TimeoutSec=2 to mythbackend.service prior to ExecStart command does function and makes things init more consistant]
    sasc-ng.service
    [Unit]
    Description=Sasc-ng
    After=oscam.service
    [Service]
    Type=simple
    EnvironmentFile=/etc/conf.d/sasc-ng
    ExecStartPre=/sbin/modprobe dvbloopback $DVBLOOPBACK_ARGS
    TimeoutSec=2
    ExecStart=/usr/sbin/sasc-ng $SASCNG_ARGS --cam-dir $CAMDIR --log $LOGFILE
    [Install]
    WantedBy=multi-user.target
    /etc/conf.d/sasc-ng
    SASCNG_ARGS="--join 0:3 --join 1:4 --join 2:5 --buffer 16M --sid-allpid --sid-nocache --cam-budget"
    DVBLOOPBACK_ARGS="num_adapters=3"
    LOGFILE="/home/mythtv/logs/sasc-ng.log"
    CAMDIR="/etc/camdir"
    oscam.service
    [Unit]
    Description=An Open Source Conditional Access Module software
    After=network.target
    [Service]
    Type=oneshot
    EnvironmentFile=/etc/conf.d/oscam
    ExecStart=/usr/bin/oscam $OSCAM_ARGS
    TimeoutSec=15
    RemainAfterExit=yes
    [Install]
    WantedBy=multi-user.target
    mythbackend.service
    [Unit]
    Description=MythTV_backend
    After=sasc-ng.service
    [Service]
    Type=simple
    TimeoutSec=2
    Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
    Environment=HOME=/usr/share/mythtv
    User=mythtv
    ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
    [Install]
    WantedBy=multi-user.target
    I will make the related changes to the open-sasc-ng AUR package which I currently maintain
    Last edited by wdirksen (2012-12-23 14:40:43)

  • [Solved] postgresql with systemd

    Hello Guys,
    I'm having problems starting the postgres with systemd.
    Following errors:
    Running systemctl start postgresql
    k@archK ~ % sudo systemctl start postgresql
    Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details.
    1 k@archK ~ %
    Running systemctl status postgresql.service got the message below:
    k@archK ~ % systemctl status postgresql.service
    postgresql.service - PostgreSQL database server
    Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled)
    Active: failed (Result: exit-code) since Sáb, 2012-12-29 19:09:19 BRT; 1min 19s ago
    Process: 1746 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (code=exited, status=1/FAILURE)
    Process: 1741 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)
    CGroup: name=systemd:/system/postgresql.service
    3 k@archK ~ %
    and journalctl -xn this:
    k@archK ~ % sudo journalctl -xn
    [sudo] password for k:
    -- Logs begin at Sáb, 2012-12-29 03:47:42 BRT, end at Sáb, 2012-12-29 19:11:49 BRT. --
    Dez 29 19:09:19 archK systemd[1]: postgresql.service: control process exited, code=exited status=1
    Dez 29 19:09:19 archK systemd[1]: Failed to start PostgreSQL database server.
    -- Subject: Unit postgresql.service has failed
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d
    -- Unit postgresql.service has failed.
    -- The result is failed.
    Dez 29 19:09:19 archK systemd[1]: Unit postgresql.service entered failed state
    Dez 29 19:09:19 archK sudo[1738]: pam_unix(sudo:session): session closed for user root
    Dez 29 19:11:27 archK udisks-daemon[430]: **** Refreshing ATA SMART data for /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
    Dez 29 19:11:27 archK udisks-daemon[430]: helper(pid 1781): launched job udisks-helper-ata-smart-collect on /dev/sda
    Dez 29 19:11:28 archK udisks-daemon[430]: helper(pid 1781): completed with exit code 0
    Dez 29 19:11:28 archK udisks-daemon[430]: **** EMITTING CHANGED for /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
    Dez 29 19:11:49 archK sudo[1786]: k : TTY=pts/0 ; PWD=/home/k ; USER=root ; COMMAND=/usr/bin/journalctl -xn
    Dez 29 19:11:49 archK sudo[1786]: pam_unix(sudo:session): session opened for user root by k(uid=0)
    Here is the postgresql.service
    [Unit]
    Description=PostgreSQL database server
    After=network.target
    [Service]
    Type=forking
    TimeoutSec=120
    User=postgres
    Group=postgres
    Environment=PGROOT=/var/lib/postgres
    SyslogIdentifier=postgres
    PIDFile=/var/lib/postgres/data/postmaster.pid
    ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data
    ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
    ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
    ExecStop= /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
    # Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
    # killing Postgres, so adjust it downward
    OOMScoreAdjust=-200
    [Install]
    WantedBy=multi-user.target
    and /etc/conf.d/postgresql
    ## Parameters to be passed to postgresql
    ## Default data directory location
    PGROOT="/var/lib/postgres"
    ## Passed to initdb if necessary
    INITOPTS="--locale en_US.UTF-8"
    ## Default log file location
    #PGLOG="/var/log/postgresql.log"
    ## Additional options to pass via pg_ctl's '-o' option
    #PGOPTS=""
    Does anyone have any idea how to fix this?
    Thanks.
    Last edited by kleitonkk (2013-01-03 23:51:41)

    Sorry for the delay, was traveling and just returned yesterday.
    lothar_m was followed as described in the post, since removed the packages twice and did the install again but the same error.
    [root@archK conf.d]# systemctl start postgresql
    Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details.
    [root@archK conf.d]#
    systemctl status postgresql.service
    ➜ ~ systemctl status postgresql.service
    postgresql.service - PostgreSQL database server
    Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled)
    Active: failed (Result: exit-code) since Thu, 2013-01-03 18:14:43 BRT; 9min ago
    Process: 10897 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (code=exited, status=1/FAILURE)
    Process: 10892 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)
    CGroup: name=systemd:/system/postgresql.service
    ➜ ~
    [root@archK conf.d]# journalctl -xn
    -- Logs begin at Wed, 2013-01-02 16:50:57 BRT, end at Thu, 2013-01-03 18:34:41 BRT. --
    Jan 03 18:25:28 archK su[11082]: pam_unix(su:session): session opened for user root by k(uid=1000)
    Jan 03 18:34:36 archK systemd[1]: Starting PostgreSQL database server...
    -- Subject: Unit postgresql.service has begun with start-up
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/7d4958e842da4a758f6c1cdc7b36dcc5
    -- Unit postgresql.service has begun starting up.
    Jan 03 18:34:36 archK postgres[11127]: LOG: could not translate host name "localhost", service "5432" to address: Name or service not known
    Jan 03 18:34:36 archK postgres[11127]: WARNING: could not create listen socket for "localhost"
    Jan 03 18:34:36 archK postgres[11127]: FATAL: could not create any TCP/IP sockets
    Jan 03 18:34:41 archK postgres[11127]: pg_ctl: could not start server
    Jan 03 18:34:41 archK postgres[11127]: Examine the log output.
    Jan 03 18:34:41 archK systemd[1]: postgresql.service: control process exited, code=exited status=1
    Jan 03 18:34:41 archK systemd[1]: Failed to start PostgreSQL database server.
    -- Subject: Unit postgresql.service has failed
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d
    -- Unit postgresql.service has failed.
    -- The result is failed.
    Jan 03 18:34:41 archK systemd[1]: Unit postgresql.service entered failed state
    /usr/lib/systemd/system/postgresql.service
    [Unit]
    Description=PostgreSQL database server
    After=network.target
    [Service]
    Type=forking
    TimeoutSec=120
    User=postgres
    Group=postgres
    Environment=PGROOT=/var/lib/postgres
    SyslogIdentifier=postgres
    PIDFile=/var/lib/postgres/data/postmaster.pid
    ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data
    ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
    ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
    ExecStop= /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
    # Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
    # killing Postgres, so adjust it downward
    OOMScoreAdjust=-200
    [Install]
    WantedBy=multi-user.target
    ➜ ~ pacman -Q |grep postgres
    postgresql 9.2.2-2
    postgresql-libs 9.2.2-2
    ➜ ~
    /etc/conf.d
    ## Parameters to be passed to postgresql
    ## Default data directory location
    PGROOT="/var/lib/postgres"
    ## Passed to initdb if necessary
    INITOPTS="--locale en_US.UTF-8"
    ## Default log file location
    #PGLOG="/var/log/postgresql.log"
    ## Additional options to pass via pg_ctl's '-o' option
    #PGOPTS=""
    /usr/lib/systemd/system/postgresql.service
    [Unit]
    Description=PostgreSQL database server
    After=network.target
    [Service]
    Type=forking
    TimeoutSec=120
    User=postgres
    Group=postgres
    Environment=PGROOT=/var/lib/postgres
    SyslogIdentifier=postgres
    PIDFile=/var/lib/postgres/data/postmaster.pid
    ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data
    ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
    ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
    ExecStop= /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
    # Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
    # killing Postgres, so adjust it downward
    OOMScoreAdjust=-200
    [Install]
    WantedBy=multi-user.target
    I'm still looking for how to solve.
    Thank you.

  • [Solved] Running mpd as user mpd with systemd without using mpd.conf

    Maybe this is tivial, but I searched about an hour without any results. I want to run mpd as user mpd. I cant use the mpd config file since mpd set the UID and GID explicitely resulting in mpd not having the necessary supplementary groups to access the locally shared music on my pc. Well I tried to run mpd with systemd by
    # systemctl start mpd
    and  the systemd contains the user mpd
    $ cat /etc/systemd/system/default.target.wants/mpd.service
    [Unit]
    Description=Music Player Daemon
    After=network.target sound.target
    [Service]
    User=mpd
    ExecStart=/usr/bin/mpd --no-daemon
    # allow MPD to use real-time priority 50
    LimitRTPRIO=50
    LimitRTTIME=-1
    # move MPD to a top-level cgroup, as real-time budget assignment fails
    # in cgroup /system/mpd.service, because /system has a zero real-time
    # budget; see
    # http://www.freedesktop.org/wiki/Software/systemd/MyServiceCantGetRealtime/
    ControlGroup=cpu:/mpd
    # assign a real-time budget
    ControlGroupAttribute=cpu.rt_runtime_us 500000
    [Install]
    WantedBy=default.target
    but it did not run as mpd.
    Well how can I run mpd as mpd? Is there a way to do it like with dropbox: dropbox@<user>.service
    Last edited by manuelschneid3r (2015-03-25 12:52:52)

    Glad you solved it. Was just typing a response and I'll still add two remarks:
    The ps|grep output showed that you run grep as root, not mpd itself (which won't have a space in the command -- the second time it only worked because the mpd group is preceded by a space).
    It sounds like it took you a while to find the drop-in configuration snippet in the mpd.service.d directory. These drop-in are shown in `systemctl status`, which is something you'd normally check in situations like these, and that might help to discover them more quickly.
    Last edited by Raynman (2015-03-25 12:58:36)

  • [SOLVED] samba does not start properly again -this time with systemd

    Definitely no luck with this one...
    So, today I've switched to a pure systemd init system, and noticed that I have this old issue again.
    (Link to my old thread: https://bbs.archlinux.org/viewtopic.php?id=142704)
    Samba doesn't start properly again, more precisely smbd is launched but not nmbd, so samba is not working as it should (for example smbtreee lists nothing).
    Last time I've solved it by putting samba long before networkmanager in the daemons array, but with systemd I'm a bit confused...
    Anyone has this issue?
    Last edited by scar (2012-11-03 07:05:42)

    I think that nmbd isn't waiting for networkmanager to start on my system, because I'm getting journal entries like
    Oct 31 00:47:21 spacebar winbindd[431]: [2012/10/31 00:47:21.556005, 0] param/loadparm.c:7969(lp_do_parameter)
    Oct 31 00:47:21 spacebar systemd[1]: nmbd.service: main process exited, code=exited, status=1
    Oct 31 00:47:21 spacebar systemd[1]: Unit nmbd.service entered failed state.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): carrier now ON (device state 20)
    Oct 31 00:47:22 spacebar kernel: r8169 0000:03:00.0: eth0: link up
    Oct 31 00:47:22 spacebar kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): device state change: unavailable -> disconnected (reason 'carrier-changed') [20 30 40]
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Auto-activating connection 'Static'.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) starting connection 'Static'
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) scheduled...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) started...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) scheduled...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) complete.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) starting...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): device state change: prepare -> config (reason 'none') [40 50 0]
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) successful.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) scheduled.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) complete.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) started...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): device state change: config -> ip-config (reason 'none') [50 70 0]
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Configure Commit) scheduled...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) complete.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Commit) started...
    Oct 31 00:47:22 spacebar rpc.mountd[462]: Version 1.2.6 starting
    Oct 31 00:47:22 spacebar systemd[1]: Startup finished in 3s 850ms 155us (kernel) + 21s 279ms 972us (userspace) = 25s 130ms 127us.
    Oct 31 00:47:23 spacebar NetworkManager[391]: <info> (eth0): device state change: ip-config -> activated (reason 'none') [70 100 0]
    Oct 31 00:47:23 spacebar ntpd_intres[441]: DNS 0.au.pool.ntp.org -> 116.66.160.39
    Oct 31 00:47:23 spacebar NetworkManager[391]: <info> Policy set 'Static' (eth0) as default for IPv4 routing and DNS.
    Oct 31 00:47:23 spacebar NetworkManager[391]: <info> Activation (eth0) successful, device activated.
    Oct 31 00:47:23 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Commit) complete.
    Oct 31 00:47:23 spacebar dbus[401]: [system] Activating service name='org.freedesktop.nm_dispatcher' (using servicehelper)
    Oct 31 00:47:20 spacebar smbd[428]: [2012/10/31 00:47:20.771872, 0] param/loadparm.c:7969(lp_do_parameter)
    Oct 31 00:47:20 spacebar smbd[428]: Ignoring unknown parameter "user client driver"
    Oct 31 00:47:20 spacebar smbd[428]: [2012/10/31 00:47:20.794252, 0] lib/interface.c:543(load_interfaces)
    Oct 31 00:47:20 spacebar smbd[428]: WARNING: no network interfaces found
    Oct 31 00:47:20 spacebar smbd[428]: [2012/10/31 00:47:20.805126, 0] smbd/server.c:1109(main)
    Oct 31 00:47:20 spacebar smbd[428]: standard input is not a socket, assuming -D option
    Oh, this started happening after putting a MUCH faster cpu and motherboard in the system, so maybe there's a race-condition there?
    Last edited by MisterAnderson (2012-10-30 04:59:46)

  • [Solved] Automating btrfs scrub with systemd

    I have a single disk laptop (no RAID) and would like to have btrfs scrub run automatically on some interval and to be automatically emailed if any errors are found.  (My data is backed up online and I can attempt a manual fix.)  I'm trying to set this up with systemd and the btrfs tools.  Here's what I figure I need:
    A systemd service to run btrfs scrub on my entire filesystem.
    A systemd timer to schedule this job weekly.
    systemd services to pause and resume a running btrfs scrub when the machine suspends and wakes up.
    A script to run btrfs status when the previous service has finished, parse the output for the number of errors, and email me if the number is greater than 0.
    A systemd service to run that script when the scrub service has completed.
    What I have so far is below.  I'm sure there are problems with it all, and I'm especially uncertain about #5, since I don't know if the After attribute of one service waits until another has completed or just started.  If anyone could take a look and give me some pointers I'd appreciate it very much.  (The python script is a hack but I'm more concerned with the systemd at the moment, unless you see obvious problems or improvements you'd like to suggest.)
    Attempt at 1 and 2:
    /etc/systemd/system/btrfs_scrub.service
    [Unit]
    Description=Run btrfs scrub on filesystem
    [Service]
    Type=forking
    ExecStart=btrfs scrub start /home
    /etc/systemd/system/btrfs_scrub.timer
    [Unit]
    Description=Weekly btrfs scrub
    [Timer]
    OnCalendar=weekly
    Persistent=true
    [Install]
    WantedBy=timers.target
    Attempt at 3:
    /etc/systemd/system/btrfs_cancel.service
    [Unit]
    Description=Pause a running btrfs scrub on suspend
    Before=suspend.target
    [Service]
    Type=oneshot
    ExecStart=btrfs scrub cancel /home
    [Install]
    WantedBy=suspend.target
    /etc/systemd/system/btrfs_resume.service
    [Unit]
    Description=Resume a paused btrfs scrub after suspend
    After=suspend.target
    [Service]
    Type=oneshot
    ExecStart=btrfs scrub resume /home
    [Install]
    WantedBy=suspend.target
    Attempt at 4:
    /home/username/Code/Scripts/btrfs_results.py
    #Runs btrfs scrub and looks for an indication of errors found, upon
    #which an email is sent.
    import subprocess
    import smtplib
    from email.mime.text import MIMEText
    def email_alert():
    text = "btrfs scrub found errors"
    addr = 'myemail@address'
    username = 'myusername'
    password = 'mypassword'
    msg = MIMEText(text)
    msg['Subject'] = 'btrfs errors'
    msg['From'] = addr
    msg['To'] = addr
    server = smtplib.SMTP('smtp.gmail.com', '587')
    server.starttls()
    server.login(username,password)
    server.sendmail(addr, addr, msg.as_string())
    server.quit()
    print('email sent')
    def main():
    cmd = ['btrfs', 'scrub', 'status', '/home']
    output = subprocess.check_output(cmd)
    output_str = output.decode("utf-8")
    output_words = output_str.split(' ')
    for w in range(0, len(output_words)):
    if output_words[w].find('error') > -1:
    if int(output_words[w - 1]) > 0:
    email_alert()
    main()
    Attempt at 5:
    /etc/systemd/system/btrfs_results.service
    [Unit]
    Description=Parse output from btrfs scrub
    Requires=btrfs_scrub.service
    After=btrfs_scrub.service
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/python /home/username/Code/Scripts/btrfs_results.py
    [Install]
    WantedBy=multi-user.target
    Last edited by 0112358 (2014-09-16 01:26:21)

    0112358 wrote:I have a single disk laptop (no RAID) and would like to have btrfs scrub run automatically on some interval and to be automatically emailed if any errors are found.  (My data is backed up online and I can attempt a manual fix.)  I'm trying to set this up with systemd and the btrfs tools.  Here's what I figure I need:
    0112358 wrote:
    A systemd service to run btrfs scrub on my entire filesystem.
    A systemd timer to schedule this job weekly.
    Should not be hard.
    0112358 wrote:systemd services to pause and resume a running btrfs scrub when the machine suspends and wakes up.
    This happens automatically with s2disk. Am I missing something?
    0112358 wrote:A script to run btrfs status when the previous service has finished, parse the output for the number of errors, and email me if the number is greater than 0.
    You might want to integrate that in the main btrfs scrub script, just after scrub is completed you will run this. Right?
    0112358 wrote:A systemd service to run that script when the scrub service has completed.
    0112358 wrote: What I have so far is below.  I'm sure there are problems with it all, and I'm especially uncertain about #5, since I don't know if the After attribute of one service waits until another has completed or just started.  If anyone could take a look and give me some pointers I'd appreciate it very much.  (The python script is a hack but I'm more concerned with the systemd at the moment, unless you see obvious problems or improvements you'd like to suggest.)
    0112358 wrote:
    Attempt at 1 and 2:
    /etc/systemd/system/btrfs_scrub.service
    [Unit]
    Description=Run btrfs scrub on filesystem
    [Service]
    Type=forking
    ExecStart=btrfs scrub start /home
    /etc/systemd/system/btrfs_scrub.timer
    [Unit]
    Description=Weekly btrfs scrub
    [Timer]
    OnCalendar=weekly
    Persistent=true
    [Install]
    WantedBy=timers.target
    Yes, why not wrap this in some sort of main bash (or python) script.
    0112358 wrote:
    Attempt at 3:
    /etc/systemd/system/btrfs_cancel.service
    [Unit]
    Description=Pause a running btrfs scrub on suspend
    Before=suspend.target
    [Service]
    Type=oneshot
    ExecStart=btrfs scrub cancel /home
    [Install]
    WantedBy=suspend.target
    /etc/systemd/system/btrfs_resume.service
    [Unit]
    Description=Resume a paused btrfs scrub after suspend
    After=suspend.target
    [Service]
    Type=oneshot
    ExecStart=btrfs scrub resume /home
    [Install]
    WantedBy=suspend.target
    Why not do nothing at all? Just let the fs continue after resume. Or is s2disk cancelling this process?
    0112358 wrote:
    Attempt at 4:
    /home/username/Code/Scripts/btrfs_results.py
    #Runs btrfs scrub and looks for an indication of errors found, upon
    #which an email is sent.
    import subprocess
    import smtplib
    from email.mime.text import MIMEText
    def email_alert():
    text = "btrfs scrub found errors"
    addr = 'myemail@address'
    username = 'myusername'
    password = 'mypassword'
    msg = MIMEText(text)
    msg['Subject'] = 'btrfs errors'
    msg['From'] = addr
    msg['To'] = addr
    server = smtplib.SMTP('smtp.gmail.com', '587')
    server.starttls()
    server.login(username,password)
    server.sendmail(addr, addr, msg.as_string())
    server.quit()
    print('email sent')
    def main():
    cmd = ['btrfs', 'scrub', 'status', '/home']
    output = subprocess.check_output(cmd)
    output_str = output.decode("utf-8")
    output_words = output_str.split(' ')
    for w in range(0, len(output_words)):
    if output_words[w].find('error') > -1:
    if int(output_words[w - 1]) > 0:
    email_alert()
    main()
    Ok
    0112358 wrote:
    Attempt at 5:
    /etc/systemd/system/btrfs_results.service
    [Unit]
    Description=Parse output from btrfs scrub
    Requires=btrfs_scrub.service
    After=btrfs_scrub.service
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/python /home/username/Code/Scripts/btrfs_results.py
    [Install]
    WantedBy=multi-user.target
    Yeah, why not wrap 1,2,4 and 5 into one script/service. Why the fine granularity?

  • [SOLVED] systemd problem: scanimage works only as root

    Hello,
    I can list the scanner with lsusb, and it works with no error messages when I run scanimage. But the image file I get is corrupted. However if I do it as root, then the file is OK.
    I've just changed to systemd and I wonder if that might have something to do with it.
    Any help with this problem would be greatly appreciated. Thank you.
    Last edited by troncoso (2012-09-05 20:05:03)

    troncoso wrote: I added my private group to those listed in the 'SystemGroup' directive in cupsd.conf, and that fixed it.
    Thank you for your comment.  My line nuber 13 of cupsd.conf looks now like this and sort of fixed the issue.
    SystemGroup sys root users
    Scanimage -L works without complain, but it takes much longer time then before. There is huge delay fore the scanning starts.
    If I stop cups by issuing /etc/rc.d/cupsd stop  The problem starts again, however there is no delay.
    The corrupted scan image file has got the "Failed cupsGetDevices" at the very beginning of it added.  That is why it is corrupted.
    If I do scanning using xsane, there is no delay nor corrupted file. It just works fine without cupsd running.
    Is there any way I can fix this issue and don't let cups to delay the scanning nor add the "Failed cupsGetDevices" at the beginning of the file ?
    Is there a way to say scanimage not to use cups  at all?
    Last edited by xsouku04 (2012-09-30 21:40:37)

  • [SOLVED] Disabling Bluetooth on boot with systemd

    I'm having a nasty-won't-go-away problem with the disabling of the bluetooth module in my Thinkpad X200s.
    Resorting to the old Arch way of disabling bluetooth on boot, I added this to my rc.local:
    /bin/echo 0 > /sys/devices/platform/thinkpad_acpi/bluetooth_enable
    The thing is, this somehow made my boots hit'n'miss: kernel panics every two boots. As soon as I commented that line from my rc.local... no more kernel panics at boot.
    I was still using an rc.conf just with daemons, and in troubleshooting the kernel panics got rid of it and used the systemd way of enabling/disabling services. My problem here is that the bluetooth service seems to be impossible to disable.
    I first tried the good ol'
    systemctl disable bluetooth.service
    Which supposedly disabled bluetooth... but didn't. Even
    systemctl stop bluetooth.service
    Does not work.
    Digging around the interwebs, I found that there are "stronger" ways to disable services with systemd, meaning "masking" services - basically links them to /dev/null
    So, I tried masking the bugger...
    systemctl mask bluetooth.service
    Reboot and... the damn bluetooth is still enabled. Only way that works is to echo 0 > /sys/devices/platform/thinkpad_acpi/bluetooth_enable... but I can't do it at boot with rc.local, otherwise I'll get the kernel panics again.
    Any ideas?
    Last edited by Onyros (2012-08-15 13:10:35)

    Onyros wrote:
    I'm having a nasty-won't-go-away problem with the disabling of the bluetooth module in my Thinkpad X200s.
    Resorting to the old Arch way of disabling bluetooth on boot, I added this to my rc.local:
    /bin/echo 0 > /sys/devices/platform/thinkpad_acpi/bluetooth_enable
    The thing is, this somehow made my boots hit'n'miss: kernel panics every two boots. As soon as I commented that line from my rc.local... no more kernel panics at boot.
    I was still using an rc.conf just with daemons, and in troubleshooting the kernel panics got rid of it and used the systemd way of enabling/disabling services. My problem here is that the bluetooth service seems to be impossible to disable.
    I first tried the good ol'
    systemctl disable bluetooth.service
    Which supposedly disabled bluetooth... but didn't.
    It disables the bluetooth service which is very different from what your write to sysfs accomplishes. Don't you really just want to blacklist the bluetooth module? Your post is a bit hard to follow...

  • [Solved] Numlock on boot (with systemd)

    I recently upgraded to systemd. Everything is working extremely well. Except that I am given to understand that systemd no doesn't use /etc/inittab, where I had added the command from the wiki that turns on numlock on each of the virtual terminals. Unfortunately the wiki doesn't have any method to do it with systemd, only the /etc/inittab method.
    This means that for a brief while, I had to live with the onerous task of hitting numlock manually. It was one of the worst weeks of my life. My index finger is still raw.
    I have come up with a somewhat-solution. I just edited /etc/bash.bashrc and added
    if [[ $( tty ) == /dev/tty? ]]; then
        setleds +num
    fi
    to it, which works quite well. It turns on num lock once you're logged in as long as you are on a virtual terminal and not on one of the /dev/pts/* ones.
    My question is, is there a better place to do this? Maybe some way to get it to turn on before you're even logged in? It doesn't really matter all that much, I'm just trying to make things "correct."
    Last edited by scott_fakename (2012-09-06 20:29:46)

    DSpider wrote:
    https://wiki.archlinux.org/index.php/Ac … _on_Bootup
    Set it in Xorg for whatever DE/WM you use and it will be active when you switch to a tty.
    Don't forget to mark it as solved.
    Yes, I tried that. I use lxdm and xfce, and setting the numlock=1 option in /etc/lxdm/lxdm.conf turns on numlock in xfce and the light in the consoles, but not the actual numlock itself in consoles.
    And Kejpi thanks, I was doing that but when I upgraded to systemd it said those would be taken out "at some point" so I was trying to find out if a permanent solution existed yet. Apparently it does not exist yet, which is fine, I was just curious. So I guess I'll stick with the bashrc method for now.
    Thanks for the replies.
    --Scott

  • [solved] How to restart all services with systemd?

    I had the habit of restarting all daemons after an upgrade so to make sure the newest libraries, configuration files etc were loaded. I did that with a shell script that restarted the daemons in order which they were listed in rc.conf. With systemd I could do something similar by first getting a list of running services and ordering a 'systemcrl restart  <servicename>' for each. But since systemd keeps track of dependencies I wonder if that would be the way to do it. Also I would need to filter out 'one shot' type services that are only needed on bootup.
    <edit>restart instead of reload</edit>
    <edit>solved it with a little script</edit>
    Last edited by rwd (2012-11-27 21:02:02)

    I think that's what systemctl snapshot does.
    snapshot [NAME]
               Create a snapshot. If a snapshot name is specified, the new snapshot will be named after it. If none is specified an automatic snapshot name is generated. In either case, the snapshot name used is printed to STDOUT, unless --quiet is specified.
               A snapshot refers to a saved state of the systemd manager. It is implemented itself as a unit that is generated dynamically with this command and has dependencies on all units active at the time. At a later time the user may return to this state by using the isolate command on the snapshot unit.
               Snapshots are only useful for saving and restoring which units are running or are stopped, they do not save/restore any other state. Snapshots are dynamic and lost on reboot.
    Then, isolate emergency.target or rescue target and switch to the snapshot.

  • What do you think of this book: "Programming and Problem Solving with Java"

    Hello Everyone:
    This may be a strange post but I am wondering if anyone has read this book and what do you think of it?
    Book Information
    Title: Programming and Problem Solving with Java
    Authors: Neell Dale, Chip Weens, Mark Headington
    Publisher: Jones & Bartlett
    Thanks for any comments

    No believe me the book is bad! The only reason I asked is I am in a university class that uses those two books for there course. The author messed up on HelloWorld.java with 4 errors at compile time! How can anyone be that stupid since they are the ones who are supposed to be teaching me the fundamentals of Java. Anyhow I just wanted other people's thoughts about the books.
    Thanks again for your input.

Maybe you are looking for

  • How can I transfer a rented movie from iPhone to iPad both on iOS 5

    Ever since I upgraded my iPad to iOS 5.0.1 I have been having a few problems, one is that Safari randomly shuts down, another is that this notice board randomly shuts down and today my biggest problem is that iTunes shuts down as soon as I choose mov

  • HAI SD EXPERS KINDLY LET ME KNOW

    HERE ARE SOME INT QUESTIONS , KINDLY LET ME KNOW THE ANSWERS 1.In a sales order, if you want to give rs 10000 more than the credit limit to your customer how do you process this scenario 2.Mention some latest tickets L1 solved in ur support project 3

  • Can't export MXF and preserve metadata

    I want to take a file from the bin, export from MXF to QT, and preserve the  metadata. Oddly, there seems to be no workflow in Adobe capable of doing this. I can't import the MXF straight into AME, because it's from the C300 which splits up the clips

  • Wrong security configuration in web.xml

    Hi all I am developing an application with JDeveloper 10.1.3.3 using ADF-BC/JSF. I have followed the example of SRDemo and my .jspx files are located in two folders : public_html/app and public_html/pricelist/ My application will have two user roles.

  • Cannot get HbO go to work on apple tv

    We have been trying to get HbO go to work on our Apple TV and cannot get it to work. We have put in the activation code on the computer and still nothing on the TV. It keeps giving new Activation codes to use. Anyone else having the same issue? Have.