Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem daemonizing script from systemd service #24

Open
vbr96 opened this issue Apr 11, 2017 · 1 comment
Open

Problem daemonizing script from systemd service #24

vbr96 opened this issue Apr 11, 2017 · 1 comment

Comments

@vbr96
Copy link

vbr96 commented Apr 11, 2017

Hello,

When I try to daemonize a script from a systemd service:

[Unit]
After=network.target
[Service]
ExecStart=/home/vbr/daemonize/daemonize /home/vbr/service/dfhome.sh
[Install]
WantedBy=default.target

the script works randomly; it writes a few bytes to the file and stop working.

The dfhome.sh script is:

#!/bin/sh

while true ; do
/bin/date >> /home/vbr/service/disk_space_report.txt
/usr/bin/du -sh /home/ >> /home/vbr/service/disk_space_report.txt
/bin/sleep 15
done

I have tried to set the stdout to the file and replace the redirection from the script, but it not works.

However, if I exec the script directly without daemonizing it (...ExecStart=/home/vbr/service/dfhome.sh
..) , it works ok. But I prefer to daemonize in order to close files, run in background, dissasociate from terminal, etc.

Thank you.

Regards,
Vic.

@drawks
Copy link

drawks commented Oct 25, 2022

Change your systemd unit to specify Type=simple there is no need to daemonize a program run under systemd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants