ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi All,
I am working in production support environment
And I have a lot of checks done daily on system
And depended on values I take specific decision
I am going to develop script to do general operation task
But my problem is this script will be a running process 24 hours
I need your advice to how to control this script to prevent resource consumption
What is the optimum solution for this
Can you give more information please? What types of system resources are you using (open files, memory, CPU cycles) and what limitations do you have? Can you run a job periodically to check the resources or are you allocating and using from the one script (and why)?
hi all
simple what i want to to
my system checks
1) disk storge
2) DB listener
3) weblogic application status
4) sql querey run every day to give some report
etc
OS: linux redhat enterprise
what i want to do
i have already cronjob to automate each task of this and sent descriptive email to me after finish
instead of lots of cronjobs i want to create shell script program run 24 hour
because i have checks run every 15 min and 20 min and 30 min and every one hour and every 4 hour
what i am afraid of
1) face before script hang in run time
2) face before script take a large amount of resources when i do it as loop to be always run
my question is
i will going to program Intelligence brain of operation depend on specific factor
that will take Decision
and i need to avoid process out of control
control resource consumption
control process hang
reach the normal solution
is that possible to do via shell scripting
is that possible to do via Perl scripting
what is the best way of programming to do that
is that good to do that or i should to monitor via my self
It sounds like your previous scripts were buggy. Well-written scripts won't experience those issues, I have many scripts that run 24/7. One in particular has been running for 161 days continuously, another for 155 days. They do their thing, sleep for a few minutes, then run again, all nested inside a while [[ 1 ]] loop with a simple sleep command at the end. I'm not using cron because these scripts are on embedded systems running a very stripped down Linux kernel and very few auxiliary programs...there is no cron.
Last edited by suicidaleggroll; 11-05-2013 at 09:03 PM.
A major problem I see in writing your own script with looping when compared to cron doing it's job is that you have to control the time AND execute many commands with lots of if-then-else etc. So if you sleep for 14 minutes, all jobs have to be completed in 1 minute and so on. And your program has to handle different time intervals for different tasks.
In any Unix, a satisfactory solution is to use system tools (like cron) and build application logic around it.
I mean, continue with the crons.
I infer from post #5 that if the poster had cron on the system, then cron would have been preferred to an application script.
Possible reasons for the script hanging at run time (faced before) are:
- Somewhere you are "shell"ing out, doing a task, looping, shelling another process and so on eventually running into "too many processes" or similar messages.
- The previous instance of the application associated with that time interval (say DB listener or disk storage) isn't over yet but holding some resource and this instance needing that resource and so on.
You will have to correct similar problems in any case.
suicidaleggroll : thanks for your reply yes my previous was buggy and have a lot of issue and this made a lot of modification but not working as i want to do
sundialsvcs : re-invent in Nagios i am already study this solution
AnanthaP : conjobs (all advice i got to make every check in separate cronjob program and it will be easy to maintain and track in condition to document well)
I think that you will find that Nagios will be "the solution to your problem." Thousands of installations throughout the planet have to "constantly monitor what their production systems are doing," and this appears to have become "the" open-source tool with which to do that sort of thing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.