> "nishanth" == nishanth ev <[EMAIL PROTECTED]> writes:
nishanth> Program will run as a daemon and you can kill it using
nishanth> kill -9
Please stop pulling out "kill -9" as your first reach.
It stops processes *dead* without giving them a chance to clean up. This is
*in general* dangero
> "James" == James Turnbull <[EMAIL PROTECTED]> writes:
James> Anyone know of a way to create a loop (or something similar) that
James> automatically schedules the execution of a sub-routine periodically from
James> within a program, for example execute check() every 600 seconds or the
like?
Jeff Pang schreef:
>> I still don't understand what the line
>>
> defined(my $pid = fork);
>>
>> is supposed to do. What does it do better than just
>>
>> my $pid = fork;
>
> You should please always do an judgement for the 'fork' call's
> returning value. It would be better:
>
> my $pid = fo
Mr. Shawn H. Corey wrote:
I assume your mainline is waiting on input. Like:
while( <> ){
...
}
Yes, that is correct.
If you use alarm, then these waits will be interrupted by the alarm. So
you need a flag to indicate this:
my $alarmed = 0;
sub wakeup {
$alarmed = 1;
#
On Tue, 2006-04-04 at 12:52 +1000, James Turnbull wrote:
> James Turnbull wrote:
> > Hi
> >
> > Anyone know of a way to create a loop (or something similar) that
> > automatically schedules the execution of a sub-routine periodically
> > from within a program, for example execute check() every 60
Nishanth Ev schreef:
> Dr.Ruud:
>> nishanth ev:
>>> Dr.Ruud:
nishanth ev:
Man, what a mess you make of your entries.
Please don't top-post. Please cut the text that you don't
react upon, especially sigs and tails.
> defined(my $pid = fork);
What does that line do? It tests
>
>I still don't understand what the line
>
defined(my $pid = fork);
>
>is supposed to do. What does it do better than just
>
> my $pid = fork;
You should please always do an judgement for the 'fork' call's returning value.
It would be better:
my $pid = fork;
die "can't fork:$!" unless
Hello,
It disassociates the process from the controlling
terminal, or the login shell. Second, it removes the
process from the process group that initiated the
program. This ensures that the process is not a
process group leader, which is required for setsid()
to run successfully.
Regards
Nishan
nishanth ev schreef:
> Dr.Ruud:
>> nishanth ev:
Please don't top-post. Please cut the text that you don't react upon,
especially sigs and tails.
>>> defined(my $pid = fork);
>>
>> What does that line do? It tests $pid for defined,
>> but the return value is not used.
>> "or die $!" missing?
>
>
Hello,
In case you want the die messages also...
chdir '/' or die "Unable to chdir to
/: $!";
open STDIN, '/dev/null' or die "Can't read
/dev/null: $!";
open STDERR, '>/dev/null' or die "Can't write to
/dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
setsid
nishanth ev schreef:
> defined(my $pid = fork);
What does that line do? It tests $pid for defined, but the return value
is not used.
"or die $!" missing?
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<
"Omega -1911" schreef:
> James Turnbull:
Please don't top-post. Please cut the text that you don't react upon,
especially sigs'n'tails.
>> Anyone know of a way to create a loop (or something similar) that
>> automatically schedules the execution of a sub-routine periodically
>> from within a pro
Hello,
Just create a daemon and then put an infinite loop.
Call the subroutines with a sleep set accordingly, so
that the subroutine will run only at specified
interval.
Below is an sample code you can use.
Program will run as a daemon and you can kill it using
kill -9
Regards
Nishanth
#!/us
On Tue, 2006-04-04 at 13:07 +1000, James Turnbull wrote:
> Mr. Shawn H. Corey wrote:
> > First question: are you running under M$ Windows or UNIX?
> >
> Unix - Linux or BSD generally
> > Second question: does this periodic function relying on data of the main
> > process?
> >
> Yes - it uses
James Turnbull wrote:
> Hi
Hello,
> Anyone know of a way to create a loop (or something similar) that
> automatically schedules the execution of a sub-routine periodically from
> within a program, for example execute check() every 600 seconds or the
> like? The program would be running as a daem
Mr. Shawn H. Corey wrote:
First question: are you running under M$ Windows or UNIX?
Unix - Linux or BSD generally
Second question: does this periodic function relying on data of the main
process?
Yes - it uses a hash defined in the mainline.
Regards
James Turnbull
--
To unsubscribe,
On Tue, 2006-04-04 at 12:52 +1000, James Turnbull wrote:
> James Turnbull wrote:
> > Hi
> >
> > Anyone know of a way to create a loop (or something similar) that
> > automatically schedules the execution of a sub-routine periodically
> > from within a program, for example execute check() every 60
On 4/3/06, James Turnbull <[EMAIL PROTECTED]> wrote:
> The mainline program is monitoring something - every x seconds I wish to
> execute a subroutine from within the mainline and return to the mainline
> after executing the subroutine to continue the monitoring.
So, it sounds as if you want your
Your best bet is to use a cron job for this. Otherwise, you'd waste server
resources. What happens when the process is killed or the server restarted?
On 4/3/06, James Turnbull <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> Anyone know of a way to create a loop (or something similar) that
> automatically s
James Turnbull wrote:
Hi
Anyone know of a way to create a loop (or something similar) that
automatically schedules the execution of a sub-routine periodically
from within a program, for example execute check() every 600 seconds
or the like? The program would be running as a daemon on the hos
20 matches
Mail list logo