Posts: 53
Joined: Thu Mar 08, 2012 7:10 pm
Location: London

Python daemon directory trouble

Mon Nov 20, 2017 9:05 am

I'm trying to create a daemon with Python's daemon library. The code works fine on my desktop machine (Mac OS X), it writes a file in the /tmp directory. On my Pi however it doesn't create a file. Needless to say, I have tried to change the directory to "/home/pi/Templates" and also create a 'tmp' directory in the root directory, with no success. What am I doing wrong?

Code: Select all

import daemon
import time

def do_something():
    while True:
        with open("/tmp/current_time.txt", "w") as f:
            f.write("The time is now " + time.ctime())

def run():
    with daemon.DaemonContext():

if __name__ == "__main__":

Return to “Raspbian”

Who is online

Users browsing this forum: No registered users and 21 guests