- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to get process creation date using script?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 06:54 AM
10-21-2002 06:54 AM
I've got a process that's been running quite a while and I want to run a script that will print the process creation date and time.
jack...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:05 AM
10-21-2002 07:05 AM
SolutionThe 'stime' from 'ps' represents the process start time. Once it exceeds 24-hours, only the date is given.
For instance, you could report the uid, command, and starting time for all processes with:
# UNIX95= ps -ef -o uid,comm,stime
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:06 AM
10-21-2002 07:06 AM
Re: How to get process creation date using script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:06 AM
10-21-2002 07:06 AM
Re: How to get process creation date using script?
I'd rather give you this example derived from 'man pstat_getproc'. It will be much more precise ...
Regards,
Jean-Louis.
#include
#include
main (argc, argv)
int argc;
char *argv[];
{
struct pst_status pst;
int target = atoi(argv[1]);
if (pstat_getproc(&pst, sizeof(pst), (size_t)0, target) != -1)
{
(void)printf("Process %d started at %s", target, ctime(&pst.pst_start));
}
else
{
perror("pstat_getproc");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:11 AM
10-21-2002 07:11 AM
Re: How to get process creation date using script?
jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:19 AM
10-21-2002 07:19 AM
Re: How to get process creation date using script?
[8238]root@freprod:/var/adm/sw/save # ps -ef | grep 6323
frs2mgr 6323 6322 226 10:59:33 ? 15:15 MxCase -d maint
root 8186 16113 2 11:20:07 pts/0 0:00 grep 6323
[8239]root@freprod:/var/adm/sw/save # ps -p 6323 -o stime
ps: illegal option -- o
usage: ps [-edaflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup]
[8246]root@freprod:/var/adm/sw/save #
Jean-Louis... I'm an idiot when trying to write c code. I wouldn't know how to compile. Thanks anyway... :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:23 AM
10-21-2002 07:23 AM
Re: How to get process creation date using script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:24 AM
10-21-2002 07:24 AM
Re: How to get process creation date using script?
You need unix95 for the -o option:-
AS Per Janmes post.
UNIX95= ps -ef -o uid,comm,stime
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:27 AM
10-21-2002 07:27 AM
Re: How to get process creation date using script?
Try this:
ps -ef | grep 6323 | sed 's/\ \{1,\}/#/g' | cut -d"#" -f6
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:28 AM
10-21-2002 07:28 AM
Re: How to get process creation date using script?
The format is:
# UNIX95= ps ...
Note carefully that the variable UNIX95 is set only for the duration of the command line. It is written as "UNIX95= ", that is with a space character *before* the 'ps' command.
This arms the UNIX95 (XPG4) behavior and thereby allows use of the '-o' option list to create a custom 'ps' output.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:31 AM
10-21-2002 07:31 AM
Re: How to get process creation date using script?
Justo, thanks... Awsome... I added grep -v to exclude the grep invocation.
All examples worked. Thanks again.
jack...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:39 AM
10-21-2002 07:39 AM
Re: How to get process creation date using script?
Juste save it in prog.c and use 'make prog'. That's all ... Call the program with a pid number.
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:43 AM
10-21-2002 07:43 AM
Re: How to get process creation date using script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:49 AM
10-21-2002 07:49 AM
Re: How to get process creation date using script?
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 09:36 AM
10-21-2002 09:36 AM
Re: How to get process creation date using script?
jack...