Sponsored Content
Full Discussion: Q's on Active Process Time
Top Forums Shell Programming and Scripting Q's on Active Process Time Post 302495253 by Chubler_XL on Wednesday 9th of February 2011 06:56:51 PM
Old 02-09-2011
On HP-UX you will need to get the process elapsed time and do some maths to calculate it's start date/time:

Code:
ELAPSED=$(UNIX95=1 ps -p $PID -o etime | tail -1)
SECONDS=$(echo $ELAPSED | awk -F"[:-]" ' BEGIN {split("1:60:3600:86400",E) } NF<5 {for(i=NF;i;i--)r+=E[i]*$(NF-i+1);print r;r=0 }')

So your next issue is going to be how to subtract X seconds from today's date and display in the required format.

If you have gnudate you can use:

Code:
date -d "- ${SECONDS} seconds" +"%Y/%m/%d %T"

Otherwise, If you have a C compiler on your HP-UX box you can use my dateadj.c program that will subtract X seconds from the current time and display in any format:

Code:
dateadj "%Y/%m/%d %T" -${SECONDS}


Last edited by Chubler_XL; 02-09-2011 at 08:03 PM.. Reason: Minor typo
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

vmstat returns good val for cpuIdle put ps shows no active process

hi i'm running a shell script that checks the amount of cpu idle either using /usr/bin/vmstat 1 2 or sar 1 2 (on unixware) before i run some tests(if cpu idle greater than 89 I run them). These tests are run on many platforms, linux(suse, redhat) hp-ux, unixware, aix, solaris, tru64. ... (5 Replies)
Discussion started by: OFFSIHR
5 Replies

2. UNIX for Dummies Questions & Answers

how to Decrease priority of a particular process in time of process creation

how to decrease priority of a particular process in time of process creation... and also how to decrease priority of a particular process after process creation.. can any one please help me out... (2 Replies)
Discussion started by: Ramkum
2 Replies

3. UNIX for Advanced & Expert Users

Process accounting and Shell process time

Hi All, I am running the following accounting on one of my executable, $ accton /home/myexe-acct $ ./myexe $ accton When I check the process timings I get the below result, Shell process time: 300ms myexe time: 100ms I want to know on why the shell(sh) process is taking so much time... (1 Reply)
Discussion started by: santoshbr4
1 Replies

4. Linux

Process start time not showing correct time

Process start time is not showing the correct time: I had started a process on Jun 17th at 23:30:00. Next day morning when I run the command "ps -ef | grep mq", the process is showing the start date of Jun 17th but the start time is 00:16:41 Day/Date is setup correctly on the server. It... (2 Replies)
Discussion started by: hemangjani
2 Replies

5. UNIX for Advanced & Expert Users

Rollover/compress log from ACTIVE process

I have some Solaris processes that run weeks at a time that create rather large log files that I would like to archive/compress daily. Instead of stopping the process, what can be done so that the log file is backed up and shrunk, but the process can still log to the open file handle without major... (7 Replies)
Discussion started by: ckmehta
7 Replies

6. Shell Programming and Scripting

determine the active processes on the system which are running since long time

Hi , Please help me shell script to determine the active processes on the system which are running since long time (2 Replies)
Discussion started by: itian2010
2 Replies

7. Shell Programming and Scripting

How to calculate time difference between start and end time of a process!

Hello All, I have a problem calculating the time difference between start and end timings...! the timings are given by 24hr format.. Start Date : 08/05/10 12:55 End Date : 08/09/10 06:50 above values are in mm/dd/yy hh:mm format. Now the thing is, 7th(08/07/10) and... (16 Replies)
Discussion started by: smarty86
16 Replies

8. UNIX for Dummies Questions & Answers

Active sessions open or long time

What kind of problems can be faced if any session which connects to unix server is open for longer time? How to find out from how much time that session is idle? :) (2 Replies)
Discussion started by: anandgodse
2 Replies

9. UNIX for Dummies Questions & Answers

Determining if a process is active in UNIX

We have written a bare bones scheduling app using bash scripts. The input to the scheduler is from a mainframe scheduling tool, and the scripts exit code is returned to the MF. The problem is that every now and again I have a script that does not complete and this is left in my Q. I am in the... (1 Reply)
Discussion started by: Charles Swart
1 Replies
date(1) 						      General Commands Manual							   date(1)

NAME
date - display or set the date and time SYNOPSIS
[mmddhhmm[[cc]yy]] sssfff]] DESCRIPTION
The command displays or sets the current HP-UX system clock date and time. Since the HP-UX system operates in Coordinated Universal Time (UTC), automatically converts to and from local standard or daylight/summer time, based on your environment variable. See in below. Options recognizes the following option: Input and output values in Coordinated Universal Time (UTC), functionally equivalent to Greenwich Mean Time (GMT), instead of in local time. Slowly adjust the time by seconds (fff represents fractions of a second). This adjustment can be positive or negative. The system's clock will be sped up or slowed down until it has drifted by the number of seconds specified. Formats The command has two forms for displaying the date and time and one form for setting them. Display the current date and time. The output is the same as for the formatting directive for all languages except the default language. See and below. Display the current date and time according to formatting directives specified in format, which is a string of zero or more formatting directives and ordinary characters. If it contains blanks, enclose it in apostrophes or quotation marks. See below. All ordinary characters are copied unchanged into the output string. The output string is always terminated with a newline character. If is specified and format is omitted, only a newline is output. Set the HP-UX system clock to the date and time specified. You require the superuser privilege. If you include the option, the specified date and time is assumed to be in Coordinated Universal Time (UTC). The numeric argument is interpreted left to right in two-digit pairs as follows: mm Month number dd Day number in the month hh Hour number (24-hour system) mm Minute number cc Century minus one yy Last two digits of the year number If omitted, the current year is used. If you attempt to set the date backwards, generates the warning, Type or the equivalent for your locale to set the clock backwards; anything else to cancel the command. When is used to set the date, a pair of date change records is written to the file (UNIX Standard only, see standards(5).) No warning is generated if date is set backwards. Formatting Directives The following formatting directives, shown without the optional field width and precision specification, are replaced by the indicated characters. If a directive is not one of the following, the result is undefined. The output for digits, characters, and words depends on the language/locale settings. See in below. The examples assume that the command was executed on Wednesday, January 12, 1994 at 7:45:58 p.m. Pacific Standard Time, using the default language. Abbreviated weekday name. For example, Full weekday name. For example, Abbreviated month name. For example, Full month name. For example, Current date and time representation. For example, Century (the year divided by 100 and truncated to an integer) as a two-digit decimal number For example, Day of the month as a two-digit decimal number For example, Day of the month as a two-character decimal number with leading space fill [ ]. For example, Combined Emperor/Era name and year. Hour (24-hour clock) as a two-digit decimal number For example, Hour (12-hour clock) as a two-digit decimal number For example, Day of the year as a three-digit decimal number For example, Month as a decimal two-digit number For example, Minute as a decimal two-digit number For example, Newline character. Emperor/Era name. Emperor/Era year. Equivalent of either AM or PM. For example, Time as %H:%M Second as a two-digit decimal number (allows for possible leap seconds) For example, Tab character. Weekday as a one-digit decimal number For example, Week number of the year (Sunday as the first day of the week) as a two-digit decimal number All days that precede the first Sunday in the year are considered to be in week For example, Week number of the year (Monday as the first day of the week) as a two-digit decimal number If the week containing January 1 has four or more days in the new year (January 1 is Thursday or sooner), it is designated as week otherwise, (January 1 is Friday or later), it is designated as the last week of the previous year, and the next week is week For example, Weekday as a one-digit decimal number For example, Week number of the year (Monday as the first day of the week) as a two-digit decimal number All days that precede the first Monday in the year are considered to be in week For example, Current date representation. For example, Current time representation. For example, Year without century as a two-digit decimal number For example, Year with century as a four-digit decimal number For example, Time zone name (or no characters if time zone cannot be determined). For example, The character. Obsolescent Directives The following directives are provided for backward compatibility. It is recommended that the preceding directives be used instead. Date in usual U.S. format. For example, Use or instead. Full month name. For example, Use instead. Abbreviated month name. For example, Use instead. Time in 12-hour U.S. format. For example, Use instead. Time in 24-hour U.S. format. For example, Use or instead. Time zone name (or no characters if time zone cannot be determined). For example, Use instead. Modified Formatting Directives Some Formatting Directives can be modified by the and modifier characters to indicate a different format or specification for the language specified in the environment variable. If the corresponding keyword and is not specified or not supported, the unmodified field descriptor value is used. The command displays the keywords and their values in the specified language (see locale(1)). Alternate appropriate date and time representation. The name of the base year in alternate representation. Alternate date representation. Offset from (year only) in the alternate representation. Full alternate year representation. Day of month using the alternate numeric symbols. Day of month using the alternate numeric symbols with leading space-character fill if applicable. Hour (24-hour clock) using the alternate numeric symbols. Hour (12-hour clock) using the alternate numeric symbols. Month using the alternate numeric symbols. Minutes using the alternate numeric symbols. Seconds using the alternate numeric symbols. Week number of the year (Sunday is the first day of the week) using the alternate numeric symbols. Weekday as number using the alternate numeric symbols Weekday number of the year (Monday is the first day of the week) using the alternate numeric symbols. Year (offset from in alternate representation. Field Width and Precision An optional field width and precision specification can immediately follow the initial of a formatting directive in the following order: The decimal digit string width specifies a minimum field width in which the result of the conversion is right- or left-justified. The default is right-justified with space padding on the left. If the string starts with "", the result is left-justified with space padding on the right. If the string starts with "", the result is right-justified and padded with zeros on the left. The decimal digit string prec specifies the minimum number of digits to appear for the and numeric directives. If a directive supplies fewer digits than specified by the precision, it will be expanded with leading zeros. prec specifies the maximum number of characters to be used from the and text directives. If a directive supplies more characters than specified by the precision, excess characters are truncated on the right. If no field width or precision is specified for a or directive, the default is for the directive, the default is for the default is for the default is EXTERNAL INFLUENCES
For information about the UNIX Standard environment, see standards(5). Environment Variables determines the interpretation of the bytes within the format string as single- and/or multi-byte characters. determines the characters used to form numbers for those directives that produce numbers in the output. The characters used are those defined by (see locale(1) and in langinfo(5)). determines the content (for example, the weekday names produced by the directive) and format (for example, the current time representation produced by the directive) of date and time strings output by the command. determines the language in which messages (other than the date and time strings) are displayed. If or is not specified or is null, it defaults to the value of If is not specified or is null, it defaults to (see lang(5)). If any internationalization variable contains an invalid setting, all internationalization variables default to (see environ(5)). determines the conversion between the system time in UTC and the time in the user's local time zone. See environ(5) and tztab(4). also determines the content (that is, the time-zone name produced by the and directives) of date and time strings output by the command. If is not set or is set to the empty string, its default value is If the or the value cannot be read from the time zone adjustment table then returns the time in International Code Set Support Single and multibyte character code sets are supported. DIAGNOSTICS
The following messages may be displayed. The date/time specification is syntactically incorrect. Check it against the usage and for the correct range of each of the digit-pairs. The character c is not a valid format directive, field width specifier, or precision specifier. The date/time you specified is earlier than the current clock value. Type (or the equivalent for your locale) to set the clock backwards; anything else to cancel the command. You need the superuser privilege to change the date. EXAMPLES
Date in Different Languages Display the date. In this example, the environment variable contains and the language environment variables are set as noted. Set Date Set the date to Oct 8, 12:45 a.m. Display Formatted Date Display the current date and time using a format. Note the use of quotation marks due to the blanks in the format. The output resembles the following: Display Formatted Date Using Local Language Conversion With the date as set in the "Set Date" example above and set to (German): generates output similar to: where the month field is four characters long, flush-left, and space-padded on the right if the month name is shorter than four characters. The day field is two characters long, with leading zeros suppressed. WARNINGS
The former HP-UX format directive has been changed to for ANSI compatibility. Changing the date while the system is running in multiuser mode should be avoided to prevent disrupting user-scheduled and time sensitive programs and processes. Also, changing the date can cause and the SCCS and subsystems to behave in an unexpected manner. The daemon should be killed prior to setting the date backwards, then restarted. SCCS files should be checked with the command (see val(1)) if deltas have been made while the clock was wrongly set. The following formatting directives may be deleted from future releases: Currently, the maximum date supported is December 31, 2037 23:59:00 UTC. AUTHOR
was developed by AT&T and HP. FILES
SEE ALSO
locale(1), stime(2), ctime(3C), strftime(3C), tztab(4), environ(5), lang(5), langinfo(5), standards(5). STANDARDS CONFORMANCE
date(1)
All times are GMT -4. The time now is 04:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy