Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

proc Daemon

by sthangav (Initiate)
on Jan 13, 2013 at 05:57 UTC ( #1013085=perlquestion: print w/ replies, xml ) Need Help??
sthangav has asked for the wisdom of the Perl Monks concerning the following question:

Can any one have sample code for making Daemon process ? please send me the code to t.sathyanarayanan@gmail.com it helps me to make my script to daemon.

Update:

Thanks Friends !

Comment on proc Daemon
Re: proc Daemon
by eyepopslikeamosquito (Canon) on Jan 13, 2013 at 06:17 UTC

    Please take the time to read How (Not) To Ask A Question before posting again.

    In particular, you need to show some effort and not ask people to email you. From How (Not) To Ask A Question:

    This is a forum, not a mailing list. If you post your email address, then you are only going to allow spam bots to find it and add it to their spam lists. If you take the time to register yourself as a user, you can go to your User Settings and check the box that says '/msg me when there's a reply' under the Miscellaneous options to receive a private message when someone replies. Otherwise, check back in about 10 to 20 minutes, and then once every hour until you have an answer that satisfies you. You should also check back the next day and maybe even the next week - you never know when someone will post a 'late' response that is very helpful and informative.

Re: proc Daemon
by LanX (Canon) on Jan 13, 2013 at 06:18 UTC
    O dear, seems like you have no access to google search! :(

    Just wait a little I'll do the search for you and will send the results ASAP to your google mail account...

    Cheers Rolf

Re: proc Daemon
by Anonymous Monk on Jan 13, 2013 at 08:22 UTC
Re: proc Daemon
by karlgoethebier (Priest) on Jan 13, 2013 at 16:42 UTC
    "please send me the code..."

    OK, but please cash in advance.

    Update: If this is beyond your budget, here is a hint.

    Karl

    «The Crux of the Biscuit is the Apostrophe»

Re: proc Daemon
by parv (Priest) on Jan 14, 2013 at 09:46 UTC
    You know you should pick up Python programming instead as I read somewhere around here that Python community is not as cynic nor as snooty as Perl one.
      Definitely! ;-)

      And what's even worse, some monks are not clever enough to spot clever cynicism and will start downvoting you.¹ =)

      Cheers Rolf

      UPDATE:

      ¹) ... for the wrong reasons.

        Don't make it a good (or appropriate) answer tho.
Re: proc Daemon
by karlgoethebier (Priest) on Jan 14, 2013 at 23:42 UTC

    Another hint:

    #!/usr/bin/perl + # daemon.pl use POSIX qw(setsid); use IO::All; use strict; use warnings; daemonize(); my $date_time; while (1) { $date_time = scalar localtime; qq($date_time\n) > io('/tmp/daemon.log'); sleep 5; } sub daemonize { defined (my $child = fork) or die qq(I really can't do that...!\n); exit if ( $child ); setsid(); open( STDIN, "</dev/null" ); # open( STOUT, ">/dev/null" ); # inferior mistake! open( STDOUT, ">/dev/null" ); + open( STDIN, ">&STDOUT" ); chdir '/'; umask(0); # ENV{PATH} = qq(what/you/really/need); + } __END__

    Update: Mea culpa! I talked pretty big before. Perhaps it would have been better if someone pointed me out on this awkward typo? I've seen hints on typos already at the monastery. Anyway - i'm sorry about this.

    Examine the result:

    tail -f /tmp/daemon.log

    Get the PID:

    # ps aux | grep '[/]usr/bin/perl ./daemon.pl' | perl -ane 'print $F[1] +'; # if many... ps aux | grep '[/]usr/bin/perl ./daemon.pl' | perl -ane 'print $F[1] . + qq(\n)'

    Get rid of it:

    Update2:

    # kill -TERM $(ps aux | grep '[/]usr/bin/perl ./daemon.pl' | perl -ane + 'print $F[1]';) # if many... kill -TERM $(ps aux | grep '[/]usr/bin/perl ./daemon.pl' | perl -ane ' +print $F[1] . qq(\n)')

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1013085]
Approved by rovf
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-12-20 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls