- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Time calculation
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
11-06-2002 04:20 AM
11-06-2002 04:20 AM
Time calculation
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2002 04:44 AM
11-06-2002 04:44 AM
Re: Time calculation
Search the forums for "date hammer" or just wait a while and Mr Hammer (otherwise known as A. Clay Stephenson) will be along to explain caljd.sh to you.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2002 05:07 AM
11-06-2002 05:07 AM
Re: Time calculation
This very simple C program (not enough controls on args and return codes) could do it ...
Regards.
#include
#include
#include
#include
main (argc, argv)
int argc;
char *argv[];
{
time_t t_now;
int days,hours,minutes,seconds;
struct stat bufstat;
if (stat(argv[1], &bufstat) != 0)
{
perror("stat");
exit(1);
}
time(&t_now);
seconds=(int)(t_now - bufstat.st_mtime);
days=seconds / 86400;
seconds=seconds % 86400;
hours=seconds / 3600;
seconds=seconds % 3600;
minutes=seconds / 60;
seconds=seconds % 60;
printf("'%s' has been modified %d days %d hours %s minutes %d seconds ago\n",
argv[1], days, hours, minutes, seconds);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2002 05:28 AM
11-06-2002 05:28 AM
Re: Time calculation
you can also use perl:
#!/opt/perl/bin/perl
use File::stat;
$st = stat($ARGV[0]) or die "No $file: $!";
$diff=time()-$st->mtime;
print "diff=$diff s\n";
to convert the seconds in Days/Hours/Minutes you can use the same syntax as Jean-Louis in his c-program
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2002 05:34 AM
11-06-2002 05:34 AM
Re: Time calculation
a5:/tmp 112 > perl -e'printf"%8.2f %s\n",24*-M$_,$_ for@ARGV' xx*
165.22 xx
0.26 xx.A
2043.71 xx.L
2573.41 xx.c
2567.42 xx.c.idx
486.43 xx.pl
1325.97 xx.sql
0.29 xxfin
1847.94 xxx
a5:/tmp 113 > ll xx*
118 -rw-rw-rw- 1 merijn softwr 15360 Oct 30 17:19 xx
515 -rw-rw-rw- 1 gert softwr 4054 Nov 6 14:17 xx.A
290 -rw-rw-rw- 1 merijn softwr 8712 Aug 13 11:50 xx.L
209 -rw-rw-rw- 1 merijn softwr 227 Jul 22 10:08 xx.c
253 -rw-rw-rw- 1 merijn softwr 24576 Jul 22 16:07 xx.c.idx
171 -rw-rw-rw- 1 merijn softwr 221 Oct 17 09:07 xx.pl
192 -rw-rw-rw- 1 linda softwr 164 Sep 12 09:34 xx.sql
358 -rw-rw-rw- 1 henk softwr 16470 Nov 6 14:15 xxfin
276 -rw-rw-rw- 1 merijn softwr 49 Aug 21 15:36 xxx
a5:/tmp 114 >