Operating System - HP-UX
1754370 Members
4982 Online
108813 Solutions
New Discussion

How to find all running scripts in HPUX

 
deepakmeethal
Established Member

How to find all running scripts in HPUX

Hi Everyone,

I am trying to find all the scripts executed on a HPUX B.11.11 system.

Scenario:

This system is new for me, and I am not sure what all scripts are getting executed by different jobs. I would like to monitor and find out all the scripts getting executed on this system.

cron logs are very helpful, where I get the info of all scripts executed by cron.

We have batch jobs and ssh execution from remote systems, need to list them too.

The script names are ending with .sh. I have tried to use ps with different options, but no luck so far. ps outputs give "-sh" only as given below.

Example ouput :

user1 4363 1 0 Jul 25 pts/20 0:00 -sh
root 29023 958 0 10:55:23 ? 0:00 sshd: root@pts/132
user1 20461 1 0 Dec 10 pts/126 0:00 -sh
user2  17797 1 0 Jan 23 pts/68 0:00 -sh

Is there way to find out the script name, for example for PID: 17797 in the above output?

 

Thanks in advance

 

3 REPLIES 3
Steven Schweda
Honored Contributor

Re: How to find all running scripts in HPUX

> This system is new for me, [...]

   "This system" means HP-UX, or what, exactly?  With what are you more
familiar?

> [...] I would like to monitor and find out all the scripts getting
> executed on this system.

   Now or ever?

> [...] I have tried to use ps with different options [...]

   With my weak psychic powers, "different options" tells me nothing.
"-o args" might provide some useful info.

   "ps" tells you what's happening _now_.  If you want info on _all_
jobs ever run, then I'd expect an occasional "ps" command to miss many
small/quick jobs.

   You might be able to add some job logging to a system-wide shell
start-up file, like, say, "/etc/profile".  (Different shells might use
different start-up files.  "man <your_shell>" for details?)

deepakmeethal
Established Member

Re: How to find all running scripts in HPUX

Thanks @Steven Schweda for the response and apologies for the late reply.

"This system" means the server I was referring to. I was trying to explain I am not familiar with this particular server and the scripts running on it. 

> [...] I would like to monitor and find out all the scripts getting
> executed on this system.

   Now or ever? - I was planning to write a script to monitor the server for a month, so that, it captures all the *.sh scripts executions. 

I have tried to use "ps -o args" in a while loop, hoping that it may capture the process whenever a ".sh" script runs. But as I mentioned, it never displays a scriptname. 

As of now, I have decided to collect the available info from cron logs and /etc/profile history.

 

Thanks and regards

Deepak 

Steven Schweda
Honored Contributor

Re: How to find all running scripts in HPUX

> [...] /etc/profile history.

   Note that a C-shell script might not use that file.  "man csh", look
for FILES.  If you want to catch a C-shell script, then you might need
to look at "/etc/csh.login", too.