[systemd-devel] Q systemd.path

Eric Lu e4cu at yahoo.com
Sat Jun 13 22:39:24 PDT 2015


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 
:

 

-        /etc/systemd/system/tst.service

-        /etc/systemd/system/tst.path

-        /usr/sbin/tst.sh

 

Any help is greatly appreciated.

 

--

Regards,

Eric Lu

 

 

[ylu at f21 ~]$ cat /proc/cmdline

BOOT_IMAGE=/vmlinuz-3.17.4-301.fc21.x86_64 root=/dev/mapper/fedora-root ro
rd.lvm.lv=fedora/swap rd.lvm.lv=fedora/root rhgb quiet LANG=en_US.UTF-8
systemd.log_level=debug systemd.log_target=kmsg log_buf_len=4M

 

 

[ylu at f21 ~]$ 

[ylu at f21 ~]$ grep -i tst dmesg.txt 

[    5.669801] systemd[1]: Installed new job tst.service/start as 212

[    9.798848] systemd[1]: Starting Tst Controller Service...

[    9.799796] systemd[1]: About to execute: /usr/sbin/tst.sh

[    9.800232] systemd[1]: Forked /usr/sbin/tst.sh as 861

[    9.800541] systemd[1]: tst.service changed dead -> start

[    9.802075] systemd[861]: Executing: /usr/sbin/tst.sh

[   10.915564] systemd[1]: Child 861 belongs to tst.service

[   10.915572] systemd[1]: tst.service: main process exited, code=exited,
status=0/SUCCESS

[   10.915833] systemd[1]: tst.service changed start -> dead

[   10.915918] systemd[1]: Job tst.service/start finished, result=done

[   10.915955] systemd[1]: Started Tst Controller Service.

[   10.916102] systemd[1]: tst.service: cgroup is empty

 

 

[ylu at f21 ~]$ 

 [ylu at f21 ~]$ cat j0.txt

Jun 13 21:02:39 f21 systemd[1]: Installed new job tst.service/start as 212

Jun 13 21:02:43 f21 systemd[1]: Starting Tst Controller Service...

Jun 13 21:02:43 f21 systemd[1]: About to execute: /usr/sbin/tst.sh

Jun 13 21:02:43 f21 systemd[1]: Forked /usr/sbin/tst.sh as 861

Jun 13 21:02:43 f21 systemd[1]: tst.service changed dead -> start

Jun 13 21:02:43 f21 systemd[861]: Executing: /usr/sbin/tst.sh

Jun 13 21:02:43 f21 logger[871]: /usr/sbin/tst.sh on Sat Jun 13 21:02:43 PDT
2015.

Jun 13 21:02:43 f21 logger[884]: /usr/sbin/tst.sh

Jun 13 21:02:43 f21 logger[887]: /usr/sbin/tst.sh

Jun 13 21:02:43 f21 logger[890]: /usr/sbin/tst.sh on Sat Jun 13 21:02:43 PDT
2015 done!

Jun 13 21:02:43 f21 tst.sh[861]: ls: cannot access /var/tmp/tst0: No such
file or directory

Jun 13 21:02:43 f21 tst.sh[861]: cat: /var/tmp/tst0: No such file or
directory

Jun 13 21:02:44 f21 systemd[1]: Child 861 belongs to tst.service

Jun 13 21:02:44 f21 systemd[1]: tst.service: main process exited,
code=exited, status=0/SUCCESS

Jun 13 21:02:44 f21 systemd[1]: tst.service changed start -> dead

Jun 13 21:02:44 f21 systemd[1]: Job tst.service/start finished, result=done

Jun 13 21:02:44 f21 systemd[1]: Started Tst Controller Service.

Jun 13 21:02:44 f21 systemd[1]: tst.service: cgroup is empty

Jun 13 21:04:41 f21 systemd[1]: Got message type=method_call sender=:1.69
destination=org.freedesktop.systemd1
object=/org/freedesktop/systemd1/unit/tst_2eservice
interface=org.freedesktop.DBus.Properties member=GetAll cookie=2
reply_cookie=0 error=n/a

Jun 13 21:04:41 f21 systemd[1]: SELinux access check
scon=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
tcon=unconfined_u:object_r:systemd_unit_file_t:s0 tclass=service perm=status
path=/etc/systemd/system/tst.service cmdline=systemctl status tst: 0

 

 

[ylu at f21 ~]$ sudo su

[sudo] password for ylu: 

[root at f21 ylu]# 

[root at f21 ylu]# systemctl status tst

● tst.service - Tst Controller Service

   Loaded: loaded (/etc/systemd/system/tst.service; 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)

 

Jun 13 21:08:37 f21 tst.sh[853]: ls: cannot access /var/tmp/tst0: No such
file or directory

Jun 13 21:08:37 f21 tst.sh[853]: cat: /var/tmp/tst0: No such file or
directory

Jun 13 21:08:37 f21 logger[890]: /usr/sbin/tst.sh on Sat Jun 13 21:08:37 PDT
2015 done!

 

 

[root at f21 ylu]# 

[root at f21 ylu]# journalctl --no-pager --all --full > ~/j.txt

 

[root at f21 ylu]# 

[root at 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

 

[root at f21 ylu]# 

[root at f21 ylu]# 

[root at 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

 

[root at f21 ylu]# 

[root at f21 ylu]# cat /usr/sbin/tst.sh

#!/usr/bin/env sh

 

echo "$0 on `date`." | logger -p info

echo "$0 `ls -al /var/tmp/tst0`" | logger -p info

echo "$0 `cat /var/tmp/tst0`" | logger -p info

echo "$0 on `date` done!" | logger -p info

 

[root at f21 ylu]# 

[root at f21 ylu]# 

[root at f21 ylu]# ls -al /var/tmp/tst*

ls: cannot access /var/tmp/tst*: No such file or directory

[root at f21 ylu]# 

[root at f21 ylu]# 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150613/073db2f7/attachment-0001.html>


More information about the systemd-devel mailing list