Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread Randal L. Schwartz
> "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

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread Randal L. Schwartz
> "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?

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread Dr.Ruud
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread James Turnbull
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; #

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread perl
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread Dr.Ruud
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread Jeff Pang
> >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

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread nishanth ev
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread Dr.Ruud
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? > >

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread nishanth ev
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread Dr.Ruud
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] <

Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread Dr.Ruud
"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

Re: Automatically scheduling the execution of a sub-routine

2006-04-03 Thread nishanth ev
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-03 Thread Mr. Shawn H. Corey
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-03 Thread John W. Krahn
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-03 Thread James Turnbull
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,

Re: Automatically scheduling the execution of a sub-routine

2006-04-03 Thread Mr. Shawn H. Corey
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-03 Thread Tom Phoenix
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-03 Thread Omega -1911
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

Re: Automatically scheduling the execution of a sub-routine

2006-04-03 Thread James Turnbull
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