Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Can you please advise a script for the following:
write linux service named system_up_duration .This service will create one file named uptime in directory ‘/temp/’. In this file the service will store the total time for which the system is up and running .The file will be updated after every one minute. If system is rebooted the time inside the file uptime should be reset to 0
2. Relevant commands, code, scripts, algorithms:
3. The attempts at a solution (include all code and scripts):
With my limited knowledge, I feel the script ( say xyz.some_ext) should be like this:
Then we can set this script to run once from rc.local during startup. However I do not know how to run this as service ( else we will have to run a cron to update time every min).
Please advise.
Thank you
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
For a friend
Ashok Deshmukh
nowrosjee wadia college
Pune, India
Last edited by fed.linuxgossip; 12-14-2010 at 03:21 PM..
Well, /tmp is a bad place for records. I would put a nicely structured line in a file using 5 minute cron + a script that can tell if it is all 'UP', and maybe daily (not another cron, but smarts in this script to see that the file date is yesterday, maybe using date in the file name, start/use a new file and summarize any old file file in a summary log with a line for the day or any span of uptime or downtime. To tell if an old file has been summarized, move them to an archive dir after summarizing them. Preiodically, add them to a zip file and delete the uncompressed files.
the path is /temp not /tmp . Moreover this is a assignment script only, not to be used in production. Plus this needs to run as a service, is running a cron necessary?
1) Check with your tutor
Is using the unix "uptime" command allowed?
2) How do you stop the process?
Some prefer using a "semaphore" file which when it exists causes the script to remove the file then exit.
Others prefer using a Shell "trap" command and issuing say a "kill -15" to stop the script.
I use both. Sometimes you can't wait for a poll.
3) Here is an example of continuous operation of a Shell script as a Service.
4) Can your process keep running ?
This is unix. Uptime in months and years is not unusual.
5) If you are using rc scripts
You have a S script to get things started on reboot.
Don't forget to have a K script which issues an appropriate "kill -15"
to get stop the background script quickly.
the path is /temp not /tmp . Moreover this is a assignment script only, not to be used in production. Plus this needs to run as a service, is running a cron necessary?
Thanks
Lots of school class code ends up in production, so why not pretend harder and get extra points? It just feels like teaching bad practice.
cron has startup costs for each test, but solves the restart on reboot problem intrinsically.
By service you just mean nohup daemon looping, sleeping? Well, after you solve the reboot problem, the total might be more complex than a good cron line. Most of the effort goes into data processing to turn the points into a report. I suppose you could look at (today) 3:05 and see the system has been up from 2010-09-31 08:35 to (today) 3:00 and just update it to say 3:05, but then you might get an error when half updated or something such. If you mmap() a file, it could be a binary update of one int.
Hi
I am trying to store the output of a command into an array in perl script.
I am able to store but the problem is i am unable to print the array line with one line space. i mean i inserted the \n in loop ...but not getting the result.
I have written like this
#!/usr/bin/perl
@a =... (2 Replies)
Hi. I wanted to create a Perl script which can take the outputs of a Perl script as it's input and temporarily store them in a document. Need help.
Thanks.:) (8 Replies)
Hi!
I want to extract the uptime from the output of the uptime command.
The output:
11:53 up 3:02, 2 users, load averages: 0,32 0,34 0,43
I just need the "3:02" part. How can I do this?
Dirk (6 Replies)
Hi,
Can you please advise a script for the following:
write linux service named system_up_duration .This service will create one file named uptime in directory ‘/temp/'. In this file the service will store the total time for which the system is up and running .The file will be updated after... (1 Reply)
Hello,
I wish to store the password in an rsync script so that when prompted it just enters the password.
I know I can set up passwordless logins, but I have never been able to do this on this particular server so I am resorting to storing the password in the script:
rsync -avz -e ssh... (4 Replies)
I'm sure this is a simple thing but I can't figure it out. In a script that I'm writing, I'd like to be able to store each line of output from "ls -l" into a variable. Ultimately I'd like to end up with something like:
for a in `ls -l`
do something with $a
doneBut that's reading each... (2 Replies)
Hi,
I want to write a service like windows service for my rhel4u5 server.And this service every day at 4:00 am connect a ftp server and download file then parse information at txt file then insert or update info at my database server(oracle).and this service can be stopped or paused by user.And... (1 Reply)
Let me preface by saying, I have looked through many threads that deal with keep the decimal, however I'm not sure that any one resolution meets my needs, ok, ok, they could. So maybe it's just that I am not understanding the resolution - therefore I am posting a new thread.
myknowledgebase=at... (2 Replies)
i'm trying to write a script that will check my os x box for uptime and autorestart gracefully if the uptime is greater than a certain number of days.
thus far i have this:
if uptime | cut -d ',' -f 1 | cut -d ' ' -f 4 -gt 10 ; then
echo "yes"
fi
this doesn't work and i've tried... (11 Replies)