Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: proc Daemon

by karlgoethebier (Curate)
on Jan 14, 2013 at 23:42 UTC ( #1013294=note: print w/ replies, xml ) Need Help??


in reply to proc Daemon

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»


Comment on Re: proc Daemon
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-07-22 22:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (129 votes), past polls