[Israel.pm] Cron Job Simulation
Gaal Yahas
gaal at forum2.org
Sun Aug 3 11:50:45 PDT 2003
On Sun, Aug 03, 2003 at 09:06:58PM +0300, Georges EL OJAIMI wrote:
> If I use sleep, does it overload something in the server?
The short answer: no.
The longer answer: no; sleep() puts the process in the S state -- which is
where most process are, in fact -- to be woken up by your kernel at some
future time.
The slightly longer answer: if your process keeps resources to itself,
then leaving it sleeping rather than invoking it later means that other
processes can't use those resources. In case of memory, this is not
really a problem, since the RAM will be paged out when it's needed by
running tasks, and paged back in when the process awakes from its sleep.
If your task opens zillions of files and keeps them open, you may run
out of file descriptors.
Of course, supposing your script is called my_perl_script.pl, you can
wrap it with a shell script, like so (my_sh_wrapper.sh):
#!/bin/sh
while 1; do
my_perl_script.pl
sleep 7200 # 2 hours
end
This bears only the cost of a running shell, which isn't much (seeing as
much of the shell's memory is shared with other instances that are
surely running on your system anyway).
--
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/
More information about the Perl
mailing list