Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: proc Daemon

by karlgoethebier (Parson)
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 + # 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 ./' | perl -ane 'print $F[1] +'; # if many... ps aux | grep '[/]usr/bin/perl ./' | perl -ane 'print $F[1] . + qq(\n)'

Get rid of it:


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

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2016-10-01 17:22 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (579 votes). Check out past polls.