You are not logged in.

#1 2015-03-14 18:36:34

Wilhelm
Member
Registered: 2012-12-06
Posts: 38

Systemd not running my service

Hello,

I have created a timed service to mirror some repositories. If I do "sudo systemctl start mirror.service", nothing happens. It should fetch git repositories. If I run my mirror script from shell, everything works.

mirror.service

[Unit]                                                                           
Description=Mirror repositories                                                  
                                                                                 
[Service]                                                                        
User=wilhelm                                                                     
Type=forking                                                                     
Nice=19                                                                          
IOSchedulingClass=2                                                              
IOSchedulingPriority=7                                                           
ExecStart=/home/wilhelm/environment/mirror

mirror

#!/bin/zsh                                                                       
(mirror-git &) > /dev/null 2>&1                                                   
(mirror-svn &) > /dev/null 2>&1    

these mirror-git and mirror-svn, will find all their repositories and use xargs to launch multiple git fetch and svn updates simultaneously.

Offline

#2 2015-03-14 18:49:41

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: Systemd not running my service

Is the service installed as a user service, or a system service?
If it is installed as a user service, and you run as root, I think it looks for the service only in the system files.
If it is installed as a system service, it runs as root (I think).  Does the mirror script have permissions for root to run it?
Is it possible that systemd will not run (as root) files that can be modified by normal users?  If it will, that is a security hole.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2015-03-14 18:58:47

Wilhelm
Member
Registered: 2012-12-06
Posts: 38

Re: Systemd not running my service

The mirror.service is located here: /etc/systemd/system/mirror.service
I'm running it as root, but I have set User=wilhelm in the mirror.service file.
So, shouldn't it run the script as me?

Offline

#4 2015-03-14 19:17:41

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: Systemd not running my service

Wilhelm wrote:

So, shouldn't it run the script as me?

Good question smile   

I think the problem is that it may run the script as you.  I am not familiar with the mirror-git and mirror-svn commands.  Is it possible they require that working directories be set? 

This may not be exactly what you are looking for, but you may want to look at systemd user services.:
https://wiki.archlinux.org/index.php/Systemd/User


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB