Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
ok i am trying to parse a .xml file every couple mins i would need to be able to do it constantly and have the parse be very specific to mabey a couple of lines it is for a live audio stream and i'm compeletly lost at this i don't know where to begin any help suggesttions i can run with or anything would be helpful.
the script would have to run constanly i would want it to run 24/7 and if possible have it start a new log file every day or once a week or something like that but the script would never be stopped. and i am trying to parse a list of ip adresses for stats on a mount point from an icecast stream. there is an xml page that comes free but it does not give past history of clients only current clients so i want to parse it to make a log.
crontab is an ancient app from UNIX systems. It runs commands periodically; user or sysadmin sets its intervals. Each user has it's own crontab table. You tell crontab at which time/times to run an specified program (your script, for example), which days, months, years, ...
Syntax is a little bit complicated because it lets you a very high range of possibilities.
Just google a little bit and you'll find it out, sure.
For the parsing, you can do a every-minute parsing. Or, if it's a better idea, parse the XML every time it changes. Think, you cannot parse it constantly. At least, you must wait until a parsing process to begin another one. It's very CPU expensive to parse anything constantly, even when XML file is little, because it ends fast, and fast it rebegins...
Think if you REALLY need to change stats every microsecond or not...
I think p_s_shah told is that if you need to parse an XML file to do your stats, you can use an already done XML parser, written on perl and named XML::Rules, downloadable from http://search.cpan.org/~jenda/XML-Ru...b/XML/Rules.pm . Once you've got your program/script working, you put it into your crontab every minute.
Your script crontab entry should look something as:
* * * * * your_xml_parser.pl
And your stats rotater (at 3:10 morning, every day):
10 3 * * * your_rotater
And your stats rotater (at 3:10 morning, every sunday):
10 3 * * 7 your_rotater
i'm am parsing for a list of clients on a streaming mount point that does a live update and i want to be able to see stats on it for like 2 in the morning but i don't want to pay for a service that is stupid and give way to much i just want what i get for free an ip so i can get a location of listener and how many people conected and a rough ideal of how long. thats it.
That will be worst than a crontab entry, for sure. If the problem is to launch new processes, bash scripting is far away from the solution. A daemon is a program that stays "doing nothing" until it needs to do something. In C, it should be something as:
first = t = time(NULL);
if((t-first) >= interval)
first = t = time(NULL);
t = time(NULL);
or just (for a minimal CPU usage but less accurate)
sleep(interval * 1000);
and run this program backgrounded (with '&' at the end of the execution line, or some other fork solution).