Home > database >  Why is my systemd service creating write protected files?
Why is my systemd service creating write protected files?

Time:02-01

I have created a systemd service that runs a java program by calling a bash file.

[Unit]
Description=Script to run JMS

[Service]
ExecStart=bash /home/user/Desktop/path_to_my_file/run_java.sh

[Install]
WantedBy=run_jms.target

When I start this process, all the files generated by the java program are write protected. However, if I execute the bash file directly from the command line, the generated files are not write protected.

What can I do to make the systemd service not generate write protected files?

CodePudding user response:

Try setting the umask for the service.

umask specifically controls the permissions granted to newly created files. It can be quite difficult to grasp at first but this page offers a very clear and detailed explanation of how it works.

CodePudding user response:

Check the userid that service is running as. Likely it is not user. You can configure that in our systemd service description like so:

...
[Service]
ExecStart=bash /home/user/Desktop/path_to_my_file/run_java.sh
User=user
Group=user
Umask=0022
...

See also

  • Related