Hi everybody, I have been struggling with this for 2 days and finally I decided to ask for your help. I created a daemon using perl. When I run the perl script the daemon is created and work perfectly. The source code of the daemon is below:
#!/usr/bin/perl use POSIX qw(setsid); chdir '/' or die "cannot change to /:$!"; open STDIN,'/dev/null' or die "cannot read stdin:$!"; #open STDOUT ,'>>/dev/null' or die "cannot write to stdout:$!"; open STDERR ,'>>/dev/null' or die "cannot write to stderr:$!"; defined(my $pid=fork) or die "cannot fork process:$!"; exit if $pid; setsid; umask 0; while(1) { #system("perl Test.pl") or die "Can't exec: $!\n"; ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOf +Week, $dayOfYear, $daylightSavings) = localtime(); if ($hour < 19) { $waitSeconds = (19-$hour) * 3600 - 60 * $minute - $second; } $date = `date`; print "The date is $date \n"; print "The number of seconds $waitSeconds\n"; sleep($waitSeconds); &loadData; }
I have a Fedora 5 system installed on my computer and I want this daemon to be created at boot time. I read different posts on internet on how to do that and I understand that you have to put a script in etc/init.d which I did :
#!/bin/sh # Source function library. . /etc/rc.d/init.d/functions # See how we were called. case "$1" in start) # Start daemons. echo -n "Start load data daemon" perl home/magda/WorkArea/MyPerlScripts/DaemonScripts/TestDaemo +n.pl ;; stop) # Stop daemons. ;; restart) $0 stop $0 start ;; esac
But still when I restart the server and then check the process list wit ps axj my daemon is not there. I will greatly appreciate your help.

In reply to How do I start a perl daemon at boot time by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.