HP-UX & need help with time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HP-UX & need help with time
# 1  
Old 12-12-2006
HP-UX & need help with time

I use HP-UX & need help with time.
I use a script to create a date stamp: /bin/date "+%m%d%H%M" to get: 12080826.
I need a way to use the "touch -t" command to create a
file with a timstamp 30 minutes prior to that stamp. (12080756)
Can anyone help?
# 2  
Old 12-12-2006
The timestamp is in seconds, so to get 30 minutes prior, subtract 1800 from it.
# 3  
Old 12-13-2006
You need to have your date in epoch seconds, subtract 1800, then format it back so touch -t can use it.

Perderabo's datecalc script in the forum FAQ does this kind of thing for you - look at the date arithmetic thread.
https://www.unix.com/showthread.php?t=13785
# 4  
Old 12-13-2006
datecalc does not handle time, just the date.

This question involves a timestamp in minutes, not seconds. Simply subtracting 30 (rather than 1800) from it would not work shortly after midnight.

Try this:
perl -e '@d=localtime time()-1800; printf "%02d%02d%02d%02d\n", $d[4]+1,$d[3],$d[2],$d[1]'

If you have not installed a recent version of perl, the HP supplied /usr/contrib/bin/perl, which is very old, should work.
# 5  
Old 12-13-2006
Excellent. I will give these options a try. I appreciate the help!!
# 6  
Old 12-13-2006
Anybody know how to transfer the date into "epoch seconds" ??
# 7  
Old 12-13-2006
Quote:
Originally Posted by obrien2003
Anybody know how to transfer the date into "epoch seconds" ??
Try:
perl -e 'print time(), "\n" '
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

DATE & TIme

Can we select the datetime from oracle database in “hhmmssnnnccyymmdd” format ? please help to solve this..... (2 Replies)
Discussion started by: Sanal
2 Replies

2. Linux

Time & Memory of Programs

Hi, I have a program called "myProg" which calls two other programs "prog1" and "prog2" with system command in it. When I type ./myProg to the terminal, everything is cool. The only things that are missing: 1) I would like to measure the time elapsed when myProg runs (I do not want the... (1 Reply)
Discussion started by: hkullana
1 Replies

3. Shell Programming and Scripting

awk & date time format

This gives: grep "qprt -o -dp -N 1 -P" printfile.log.1216 |awk '{print $7, $9}' |grep lpc1z The output like below: lpc1z /cerner/d_prod/print/ccltemp4235396d030a.dat.tmp.1216075330] lpc1z /cerner/d_prod/print/ccltemp4235396d036a.dat.tmp.1216075634] lpc1z... (2 Replies)
Discussion started by: Daniel Gate
2 Replies

4. Shell Programming and Scripting

About date & time difference

Hello All, I was having a look on threads on the Forum about time calculation but didn't find exactly this issue. For instance, if we have these 2 dates, begin & end : 20100430235830 20100501000200 Is there anyway, awk, ksh, perl to calculate the difference in sec and get for... (6 Replies)
Discussion started by: rany1
6 Replies

5. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

6. Shell Programming and Scripting

Getting modified time & filename only

Hi, When we use "ls -l" we are getting like below, -rw-r--r-- 1 mdskl mds 4161479 Apr 12 14:57 VTTF2008.20080412145748.cc But i need only modified time and filename only like below, Apr 12 14:57 VTTF3008.20080412145748.cc Thanks-:) Senthil (4 Replies)
Discussion started by: senthil_seera
4 Replies

7. UNIX for Advanced & Expert Users

Time Calculations & Conversions

I have script that runs based on time variables passed in the command line. The first command argument is a timer, in seconds, of how often to execute a certain loop in the script. The second command argument is the end time of the script, in military time. Below is an example of the command line:... (1 Reply)
Discussion started by: Nysif Steve
1 Replies

8. UNIX for Advanced & Expert Users

Response time & IO max

in HP-UX how i can measure the response time and how can i find the maximum IO (1 Reply)
Discussion started by: salhoub
1 Replies

9. UNIX for Dummies Questions & Answers

Backup Date & Time

:confused: I'm not really sure about the default backup date & time in our Unix system and I would like to change it to a convienient time...how do I do that? Please help? (1 Reply)
Discussion started by: EbeyeJJ
1 Replies

10. UNIX for Dummies Questions & Answers

Time & Date Command

Hey all, When you run the 'ls -la' command it'll show you the time and dates of all files/directories. Now what I am trying to do is create a script that will tell me what files haven't been used in over the past 1 month and what the time and date is that the files that haven't been accessed in... (2 Replies)
Discussion started by: merlin
2 Replies
Login or Register to Ask a Question