'systemctl daemon-reload' cant see new service

Hi All,
I need to add manually a new service.

here is body of touchFake.service

[Unit]
Description = creating fake file /var/lock/fakeGpuForSlurm
Before = munge.service

[Service]
ExecStart = /root/scripts/touchFakeGpuForSlurmLockFile.sh
User=slurm
Group=slurm

[Install]
WantedBy = multi-user.target

and does not matter where i put it in /etc/systemd/system/ or /usr/lib/systemd/system/
after command ‘systemctl daemon-reload’ or even reboot I still got

[root@localhost tomjan]# systemctl enable touchFake.service
Failed to enable unit: Unit file touchFake.service does not exist.

Does you hav an ide what could be wrong?
Thank you

The use of the word “touch” is confusing the issue here.
“touch” is a command to change file timestamps, but if used with a non-existing file name it will create an empty file. So if at a shell command line you type:

$ touch Fake.service

touch will create an empty file named Fake.service which you can then open with your favorite editor and populate with what ever contents you desire.

So open your text editor and save a file named FakeGPU.service
and add the contents as described above with the following changes.
Don’t execute scripts from roots folder, put them in /usr/local/bin/
Rename your script to FakeGpuForSlumLockFile.sh
So this line would be:
ExecStart=/usr/local/bin/FakeGpuForSlumLockFile.sh

Anyway I don’t know if this will help because I think you are misunderstanding words that describe commands in the guide you are using.

Hmm… seems to work for me…

% sudo cat /usr/lib/systemd/system/touchFake.service 
[Unit]
Description = creating fake file /var/lock/fakeGpuForSlurm
Before = munge.service

[Service]
ExecStart = /root/scripts/touchFakeGpuForSlurmLockFile.sh
User=slurm
Group=slurm

[Install]
WantedBy = multi-user.target

% sudo systemctl daemon-reload
% sudo systemctl enable  touchFake.service
Created symlink from /etc/systemd/system/multi-user.target.wants/touchFake.service to /usr/lib/systemd/system/touchFake.service.

What are the permissions on your file? In my case:

% ls -l /usr/lib/systemd/system/touchFake.service 
-rw-r--r-- 1 root root 221 Mar 24 21:09 /usr/lib/systemd/system/touchFake.service

Do not put unmanaged files under /usr/lib. All local customizations should work from under /etc

1 Like

Hi All,
Guys I don’t know how it is possible but next day i was able to set fake gpu service without any problems i met day before. (for a while i was sure it is problem of setting it up on vbox machine. but i set it on rocky host server and on rocky vm and both works)

Finally i set it up like this

[root@localhost tomjan]# ls -alh /etc/systemd/system/touchFake.service
-rw-r–r–. 1 root root 505 Mar 25 14:46 /etc/systemd/system/touchFake.service

[root@localhost tomjan]# cat /etc/systemd/system/touchFake.service
[Unit]
Description = creating fake file /var/run/slurm/fakeGpuForSlurm
Before = munge.service

[Service]
Type=oneshot
RemainAfterExit=yes
RuntimeDirectory=slurm
RuntimeDirectoryMode=0700
ExecStart =-/usr/bin/sh /usr/local/bin/touchFakeGpuForSlurmLockFile.sh
User=slurm
Group=slurm

ExecStartPre=-/usr/bin/mkdir -p /run/slurm
ExecStartPre=-/usr/bin/chown slurm.slurm /run/slurm
ExecStartPre=-/usr/bin/chmod -R 700 /run/slurm

[Install]
WantedBy = multi-user.target

[root@localhost tomjan]# ls -alh /usr/local/bin/touchFakeGpuForSlurmLockFile.sh
-rwxr-xr-x. 1 root root 37 Mar 25 12:17 /usr/local/bin/touchFakeGpuForSlurmLockFile.sh

[root@localhost tomjan]# cat /usr/local/bin/touchFakeGpuForSlurmLockFile.sh
touch /var/run/slurm/fakeGpuForSlurm

Thank you for your help!