http://qs1969.pair.com?node_id=348946


in reply to Cron or running process?

Well in your specific application it appears that option 2 and 3 are very similar (with regards to frequency of execution) so the added system resources being chewed up by a deamon running constantly in the background does not outweight the need to be real time. I would go with number 2. This option for your scenerio will be most practical, applicable and resource friendly.

If you fell the need to be almost real time you can setup a cron job to run every minute and check the target files and still be more efficient than a running app in the background. Even if a running app does this very thing (meaning run at startup and poll the file every 60 seconds then sleep for 60 seconds and do it again) it is still using system resources while sleeping.


www.perlskripts.com

Replies are listed 'Best First'.
Re: Re: Cron or running process?
by l3nz (Friar) on Apr 29, 2004 at 17:46 UTC
    I'd go for cron, keeping in mind that:
    • It could hang and not work (though the same could be for your own code, and I guess that would be more likely than cron itself)
    • More than one instance of your script could be running at the same time. Play it safe and check before doing things that will break if done by two different process at once. Having a database backend with transactions might help.
    • Log, log and log again. You want to know whether your thing ran, whether it completed okay, what went wrong. Log it before, don't wonder what went wrong afterwards.
    I guess this is my $0.02