On Sat, Jun 13, 2015 at 10:39:24PM -0700, Eric Lu wrote:
> Hi,
> 
>  
> 
> I tested the functionality of system.path in a Fedora 21 workstation. The
> script was executed even though the file specified in ‘PathExists=”,
> /var/tmp/tst0, did not exist. Is there something I misunderstand or …:
> 
  
  Basically, you have enabled tst.service to be started during boot. So it
is started no matter if file exists or not.  You have also enabled tst.path,
so tst.service should be started again when the file appear.

  You should only enable .path unit. Additionaly, you can guard execution
of .service by ConditionPathExists= (or similar, check man systemd.unit).
 
> 
> [root@f21 ylu]# systemctl status tst
> 
> ● tst.service - Tst Controller Service
>    Loaded: loaded (/etc/systemd/system/tst.service; enabled)
                                                      ^^^^^^^  it's enabled
                                                      
>    Active: inactive (dead) since Sat 2015-06-13 21:08:37 PDT; 1min 18s ago
>   Process: 853 ExecStart=/usr/sbin/tst.sh (code=exited, status=0/SUCCESS)
> Main PID: 853 (code=exited, status=0/SUCCESS)
> 
> [root@f21 ylu]# cat /etc/systemd/system/tst.path
> 
> [Unit]
> Description=Activate test Service 
> # DefaultDependencies=no
> 
> [Path]
> PathExists=/var/tmp/tst0
> 
> Unit=tst.service
> 
> # [Install]
> # WantedBy=multi-user.target

  No install instructions for tst.path.
  
> 
> [root@f21 ylu]# cat /etc/systemd/system/tst.service 
> 
> [Unit]
> Description=Tst Controller Service
> 
> [Service]
> Type=oneshot
> Environment=TERM=linux
> # NotifyAccess=all
> ExecStart=/usr/sbin/tst.sh
> 
> [Install]
> Also=tst.path
> WantedBy=multi-user.target

  tst.service install instruction.

-- 
Tomasz Torcz              ,,If you try to upissue this patchset I shall be 
seeking
xmpp: zdzich...@chrome.pl   an IP-routable hand grenade.'' -- Andrew Morton 
(LKML)

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to