How to log start/stop time of ALL processes

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to log start/stop time of ALL processes
# 1  
Old 12-13-2007
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  
Old 12-13-2007
In the way you've described it :
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 :
echo "$0 start date=`date`" >> some log file

the script content goes here.....and
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: start date Thu Dec 13 07:54:30 PST 2007 start date Thu Dec 12 05:35:30 PST 2007 start date Thu Dec 11 06:36:30 PST 2007 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  
Old 12-13-2007
Is there a cron log in /var/adm/cron?
# 4  
Old 12-13-2007

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. Smilie

Last edited by bluesky099; 12-14-2007 at 12:06 AM..
# 5  
Old 12-14-2007
Originally Posted by bluesky099
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  
Old 12-14-2007
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  
Old 12-16-2007
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,

* * * * 1 && yourscript.ksh &&

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Find processes by start time

How do I find the process ( which might got completed ) which were ran at specific time. for e.g. I should be able to find below process after 2 hrs if I find by time 04:00 myuser 23285 22522 0 04:00 pts/0 00:00:00 /home/myuser/bin/abc.ksh (3 Replies)
Discussion started by: sameermohite
3 Replies

2. Shell Programming and Scripting

how to synch 2 processes to start at the same time

Hey Excuse me if this question is repeated everywhere but I am still new with scripting and I couldn't apply what I found to my case :confused::confused: I am trying to run a rec process on a ssh client and at the same time play a file from my computer so i tried this #!/bin/bash echo... (3 Replies)
Discussion started by: Antaha
3 Replies

3. UNIX for Advanced & Expert Users

Multiple processes write to log file at the same time

If we have 3 process to write to same log file at the same time like below. will it cause the data outdated because the multiple process writing same time? It this a safe way to keep the log for multiple process? p1 >> test.log &; p2 >> test.log &; p3 >> test.log & Thanks, (1 Reply)
Discussion started by: casttree
1 Replies

4. SuSE

List of processes/ which ones to stop

Hi there, I've install a testserver with SLES 11.0! I'll install/test XEN + WebServer not all things at the moment! In a first time, I'd like to stop all unuse processes... but I don't understand all processes! As someone a list of all processes with his signification and which should/could... (3 Replies)
Discussion started by: hiddenshadow
3 Replies

5. UNIX for Dummies Questions & Answers

Stop/Start vs. Restart

Is there any functional difference between: issuing separate stop/start commands like this; super (handler) (instance) stop super (handler) (instance) start versus issuing a single recycle command like this; super (handler) (instance) restart (3 Replies)
Discussion started by: Newbix
3 Replies

6. Solaris

How to start/stop processes

Please anyone tell me In my last interview the HR asks me how to monitor, start,stop & kill the various processes and subprocesses. Please anyone explain me clearly. It's my personal request (3 Replies)
Discussion started by: suneelieg
3 Replies

7. Shell Programming and Scripting

Start program in background (or start crontab ahead of time)

Hey! I'm working on a script that will add a user, create some configfiles, and add a crontab for the user. The crontab looks like the following: @reboot /home/user/program config.conf & I would like for this process to start at the end of my script under the corresponding username by... (0 Replies)
Discussion started by: noratx
0 Replies

8. Shell Programming and Scripting

Servers Start and Stop

HI I am using below code to start and stop servers but it is not working ,how to run the script please suggest me ,if any errors in the script please let me know. #!/bin/bash IMS_START="/Webserver/AppServer/bin/" IMS_STOP="/Webserver/AppServer/bin/" case "$1" in ... (1 Reply)
Discussion started by: RG18173
1 Replies

9. UNIX for Advanced & Expert Users

Log 'syslog start/stop/restart' messages

How can I tell my syslog.conf to log "syslog start/stop/restart" messages on a Solaris box? (1 Reply)
Discussion started by: SunnyK
1 Replies

10. Shell Programming and Scripting

Checking before start and stop processes

Hi, I have 2 start and stop sh. Start sh -------- This will start few processes. Example code: echo "start process : lgz200 /pipe=test_jobs" nohup lgz200 /db=test/test1@test1 /pipe=test_jobs > ../log/lgz200_j.log & echo "echo \"stop process (pid=$!): lgz200 /pipe=test_jobs\"" >>... (3 Replies)
Discussion started by: maldini
3 Replies
Login or Register to Ask a Question