Systemd learning (Requires= , Wants= )

Hi,

I am testing the functionality of Requires and Wants
I am just using my 2 service files, msgg and mssgg.
mssgg.service service has msgg.service as Requires
I have made no link to msgg.service, so that it will not be executing(I also referenced a non-existent script in its StartExec to make it fail)
I have link mssgg.service in rescue.target.wants, to execute in rescue mode.

As per my understanding, mssgg shouldn't execute , as msgg is not active, but it executes.
Same is happening when I use Wants instead of Requires.

(My script just writes a line to a file and sleeps for some seconds. File is created new always)

Where am I going incorrect.

msgg.service

[Unit]
Description=my service

[Service]
ExecStart=/home/jd/msggscript

mssgg.service

[Unit]
Description=my master service
Requires=msgg.service

[Service]
ExecStart=/home/jd/mssggscript

In /home/jd/mssggscript

#!/bin/bash
if [ -f /home/jd/masterfnew ]
then
rm -f /home/jd/masterfnew
fi
sleep 10
echo -e "\n\n status of Msgg.service is `systemctl is-failed msgg.servivce`" > /home/jd/masterfnew
echo -e "\n THIS IS  USER SERVICE RUNNING \n \n" >> /home/jd/masterfnew
echo -e ""
exit 0
 ls -l rescue.target.wants/
total 0
lrwxrwxrwx 1 root root 16 Apr  8 04:26 mssgg.service -> ../mssgg.service
lrwxrwxrwx 1 root root 39 Oct 17 17:15 systemd-update-utmp-runlevel.service -> ../systemd-update-utmp-runlevel.service

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.