Skip to content

Problem daemonizing script from systemd service #24

Description

@vbr96

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions