LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2013, 03:00 PM   #1
maxosmanpad
LQ Newbie
 
Registered: Nov 2013
Location: Shell
Posts: 3

Rep: Reputation: Disabled
Need Advice for This Programming way


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
 
Old 11-03-2013, 10:28 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
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)?

Sorry I only have questions, not answers.
 
Old 11-04-2013, 01:40 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
I think you need not run it all time long, but use crontab to wake it up time by time (and let it simply exit if nothing to do)
 
Old 11-05-2013, 08:48 AM   #4
maxosmanpad
LQ Newbie
 
Registered: Nov 2013
Location: Shell
Posts: 3

Original Poster
Rep: Reputation: Disabled
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
 
Old 11-05-2013, 09:01 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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.
 
Old 11-05-2013, 09:23 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
Uhhh... are(n't) you trying to re-invent Nagios?
 
Old 11-05-2013, 11:08 PM   #7
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
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.

OK
 
Old 11-06-2013, 05:47 AM   #8
maxosmanpad
LQ Newbie
 
Registered: Nov 2013
Location: Shell
Posts: 3

Original Poster
Rep: Reputation: Disabled
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)

thank you all my friends and for your advises
 
Old 11-06-2013, 06:37 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
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.

Actum Ne Agas: Do Not Do A Thing Already Done.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice on a programming language sdad Linux - Software 7 01-16-2011 09:04 AM
Looking for advice on getting back into programming tseruzhy0 General 6 03-14-2008 01:01 AM
Advice on Programming maromi Programming 1 02-15-2008 01:00 AM
programming advice creolophus Programming 4 08-15-2006 10:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration