in reply to Re: how to make a demon in perl?
in thread how to make a demon in perl?

what is the difference between chdir to the "/" directory or to /var/log/ for ex? which one is the safest ? I had a look at the daemonize module; looks pretty neat.

Replies are listed 'Best First'.
Re: Re: Re: how to make a demon in perl?
by RMGir (Prior) on Oct 01, 2002 at 13:03 UTC
    Type "mount" at your command line. You'll see a listing something like this:
    $ mount /dev/sda1 on / type ext3 (rw) none on /proc type proc (rw) /dev/sda7 on /data type ext3 (rw) none on /dev/pts type devpts (rw,gid=5,mode=620) none on /dev/shm type tmpfs (rw) /dev/sda5 on /tmp type ext3 (rw) /dev/sda3 on /usr type ext3 (rw) /dev/sda2 on /var type ext3 (rw) nfsserver:/vol/office/home on /home type nfs (rw,addr=nfsserver) nfsserver:/vol/office/log on /log type nfs (rw,addr=nfsserver)
    Each of the /dev/sd\d items is a different disk on your system, and the "type nfs" entries are remote volumes you're connected to.

    The system can't operate without / being mounted, so it doesn't make a difference if that's your current working directory. If / is dead, the system definitely needs a reboot anyways, at least.

    /var/log (well, /var at least) is usually a separate device, which the system could theoretically live without.

    In fact, if your daemon logs via syslog, as such things probably should, the admin can unmount /var/log even if lots of daemons normally log there by reconfiguring syslogd to log somewhere else.

    But, in general, /var/xxx is probably an ok 3rd choice, with / being best, and /tmp probably being 2nd.
    --
    Mike

      BTW I know about how unix works :-) thanx for the advice anyway.
Re: Re: Re: how to make a demon in perl?
by zigdon (Deacon) on Oct 01, 2002 at 13:28 UTC
    If you have a log file you're writing to in /var/log, then chdir to /var/log - you're already going to keep /var/log busy, might as well not keep / busy too. If you're not logging directly, (perhpas you're using syslog, like a good daemon), then chdir to /.

    -- Dan