You are not logged in.

#1 2015-07-08 08:15:12

Heavy Rain
Member
Registered: 2011-09-21
Posts: 15

[SOLVED] Little systemd service problem

Hey,

I'm new to systemd and I'm trying to set up a really easy service file. It's supposed to generate a list of explicitly installed packages.
The file is as follows (/etc/systemd/system/pkglist.service):

[Unit]
Description=Backup a list of installed software

[Service]
Type=oneshot
ExecStart=/usr/bin/pacman -Qet > /home/cons/Dropbox/Dokumente/Dokumente/Arch/pkglist.txt

Running it with systemctl start pkglist.service returns an error and systemctl status pkglist.service returns:

● pkglist.service - Backup a list of installed software
   Loaded: loaded (/etc/systemd/system/pkglist.service; static; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mi 2015-07-08 10:07:22 CEST; 6s ago
  Process: 6284 ExecStart=/usr/bin/pacman -Qet > /home/cons/Dropbox/Dokumente/Dokumente/Arch/pkglist.txt (code=exited, status=1/FAILURE)
 Main PID: 6284 (code=exited, status=1/FAILURE)

Jul 08 10:07:22 cons-arch systemd[1]: Starting Backup a list of installed software...
Jul 08 10:07:22 cons-arch pacman[6284]: Fehler: Paket '>' wurde nicht gefunden
Jul 08 10:07:22 cons-arch pacman[6284]: Fehler: Paket '/home/cons/Dropbox/Dokumente/Dokumente/Arch/pkglist.txt' wurde nicht gefunden
Jul 08 10:07:22 cons-arch pacman[6284]: Warnung: '/home/cons/Dropbox/Dokumente/Dokumente/Arch/pkglist.txt' ist eine Datei, Sie möchten vielleicht -p/--file benutzen.
Jul 08 10:07:22 cons-arch systemd[1]: pkglist.service: Main process exited, code=exited, status=1/FAILURE
Jul 08 10:07:22 cons-arch systemd[1]: Failed to start Backup a list of installed software.
Jul 08 10:07:22 cons-arch systemd[1]: pkglist.service: Unit entered failed state.
Jul 08 10:07:22 cons-arch systemd[1]: pkglist.service: Failed with result 'exit-code'.

So, as far as I can tell, pacman wants to treat ">" and the file path as packages.
However, running /usr/bin/pacman -Qet > /home/cons/Dropbox/Dokumente/Dokumente/Arch/pkglist.txt as root returns the desired outcome and I end up with a file of installed packages.

Why is there a difference between running it in a terminal and executing it with systemd?

I'm sorry if the answer is right in front of me and I'm just too dumb to see it wink

Last edited by Heavy Rain (2015-07-08 09:41:09)

Offline

#2 2015-07-08 08:24:15

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Little systemd service problem

See the man page (systemd.service) section on Command Lines...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2015-07-08 08:44:03

Heavy Rain
Member
Registered: 2011-09-21
Posts: 15

Re: [SOLVED] Little systemd service problem

Thank you for the reply!

Quotes don't seem to work though, it returns the same error.

However, I found this passage in the man page:

This syntax is intended to be very similar to shell syntax, but only the meta-characters and expansions described in the following paragraphs are understood.
Specifically, redirection using "<", "<<", ">", and ">>", pipes using "|", running programs in the background using "&", and other elements of shell syntax are not supported.

It seems redirections are just not supported?

Offline

#4 2015-07-08 08:49:11

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Little systemd service problem

That's it. You could always work around it by putting the redirection in a script and calling that...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2015-07-08 09:41:22

Heavy Rain
Member
Registered: 2011-09-21
Posts: 15

Re: [SOLVED] Little systemd service problem

Thank you, I'll look into that!

Offline

Board footer

Powered by FluxBB