The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pERL SCRIPT FOR MONITORING DATE/TIME STAMPS FOR START AND STOP OF APPLICAION IN A LOG FREDDIE091970 Shell Programming and Scripting 4 03-31-2008 09:59 PM
Start Stop Apache MILLERJ62 AIX 2 12-27-2005 05:40 PM
Checking before start and stop processes maldini Shell Programming and Scripting 3 07-22-2005 02:35 AM
Stop/Start proftpd Lomic UNIX for Dummies Questions & Answers 1 12-09-2004 09:38 AM
Start/Stop Script jjv1 UNIX for Dummies Questions & Answers 2 12-16-2003 04:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-13-2007
bluesky099 bluesky099 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 8
Question How to log start/stop time of ALL processes

Hi all,

I joined this forum today and this is my first question. I thank you all for viewing it. I will try to be brief.

The OS: HP-UX B.11.11 U 9000/800

There are lot of cron scheduled perl scripts running on this server, which do different things at different time. Some of them process incoming csv files (from some server), some scripts upload that data to a oracle DB, some anther scripts process that data and populate some other table and so on. I am sorry if this is confusing, but there are more than 300 scripts running (at different time per day). They can run for 10 seconds or 3 days.

Now my problem:

My boss wants to monitor all scripts' start-stop time in real time. Something like this

Script name----Start date---Start time---Stop date---Stop Time
Script1 mm/dd/yyyy hh:mm:ss mm/dd/yyyy hh:mm:ss
....

(I need to do this for 3 different logins, which have different perl scripts scheduled).

Is there any way (without manually running PS command for each script) so that the start and stop time of all these scripts will be logged automatically?

I am sorry if I have broken any rule of this forum by putting this in wrong thread. I appreciate any input from all of you Unix Gurus.
  #2 (permalink)  
Old 12-13-2007
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,318
In the way you've described it :
Quote:
Script name----Start date---Start time---Stop date---Stop Time
Script1 mm/dd/yyyy hh:mm:ss mm/dd/yyyy hh:mm:ss
I can think of only one possible way - putting such lines to be executed in the beginning and at the end of each script, like :
Code:
#!/bin/bash 
echo "$0 start date=`date`" >> some log file
the script content goes here.....and
Code:
echo "$0 end date=`date`" >> some log file
This will require manual editing all of your scripts, which, may not be written in the same language, thus creating additional obstacles. Other disadvantage is that maintaining such log file will be sort of "not-well-arranged" because random scripts will write lines of info at pretty much random times, i.e. such file may look like :

Quote:
disk_space_usage.sh start date Thu Dec 13 07:54:30 PST 2007
mta-monitor.pl start date Thu Dec 12 05:35:30 PST 2007
oracle-trans.py start date Thu Dec 11 06:36:30 PST 2007
disk_space_usage.sh end date Thu Dec 14 08:54:30 PST 2007
which won't be very readable. That's what I can produce on prima vista, I'll be glad to hear other opinions and solutions.
  #3 (permalink)  
Old 12-13-2007
prowla prowla is offline
Read Only
  
 

Join Date: Nov 2007
Posts: 165
Is there a cron log in /var/adm/cron?
  #4 (permalink)  
Old 12-13-2007
bluesky099 bluesky099 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 8
Smile

Thanks sysgate and prowla for your replies.

Sysgate- you are right, modifying every perl script is not possible. The scripts were written 5 to 10 years back, and probably the debugging options were not on their priority list. I was affraid that I might not have any other option than modifying each script.

prowla- That is excellent! The log file is there, and seems to contain useful information. Now I need to worry about parsing that file and generating some useful reports! I will try to write a simple shell or perl script which can list ALL processes for a certain user, for a specific time period. One problem I can foresee is that it may not contain the stop time - any ideas on that?

I will keep you posted guys, Thanks for your support and spending time on this.

Last edited by bluesky099; 12-14-2007 at 12:06 AM..
  #5 (permalink)  
Old 12-14-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by bluesky099 View Post
Sysgate- you are right, modifying every perl script is not possible. The scripts were written 5 to 10 years back, and probably the debugging options were not on their priority list.
However there is nothing to stop you using a wrapper script which does the timing and calls the original script.
  #6 (permalink)  
Old 12-14-2007
bluesky099 bluesky099 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 8
Thanks porter, but there are hundreds of scripts running, and they are either Ksh or Perl scripts. Do you mean a separate wrapper for every script? A common wrapper is not possible, since I am not supposed to modify cron entry.
  #7 (permalink)  
Old 12-16-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
A common wrapper should be the way as writing a wrapper for 'n' number of scripts is not an ideal way

How about something like,

Code:
* * * * 1 common_wrapper.sh && yourscript.ksh && common_wrapper.sh
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0