Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Solaris 10 (x86) and Windows XP Pro SP2
Posts: 596
Rep:
Changing the Time Format in Solaris 10?
Hi,
This is a stupid question, but I have been working with OpenVMS systems in the past, and VMS logs times in this format below:
HH:MM:SS:00
In UNIX, how can I add the time format were the time shows in CENTISECONDS like the one in above? For example, I want all applications including the time in which users logged on in the format as below:
12:00:59.75
I have a gut feeling that this is impossible to do in UNIX, but I hiope somebody has some ideas.
I'm not sitting in front of a Sol 10 server right now, but I think you're correct in your assumption. You can set the date as root using the "date" command.
Check the manpage for the date command to see how specific you can get, but I believe it's only down to the second. I could be wrong, though. Hopefully, so
I had to do some work tonight and logged into one of our sol 10 boxes and it looks like date is only accurate (or displayable) to the second. I ran date with -x just to get the usage output.
Quote:
root # uname -rv
5.10 Generic_127111-09
root # date -x
date: illegal option -- x
usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]
I've always thought this was strange, since "time" does display microseconds when you measure actions.
Sorry I can't help you out with that
Maybe there's a custom package out there for this ???
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
That's it. Save the new file as "datems.c" which would mean date milli/micro seconds.
To run the command, use "./datems" or copy it to /usr/bin and simply run "datems".
Note that this command isn't going to change the way system timestamps are displayed. It just demonstrates that Solaris/Unix/Linux can provide sub-second timestamps like or better than VMS.
Distribution: Solaris 10 (x86) and Windows XP Pro SP2
Posts: 596
Original Poster
Rep:
So, after this, will my clock on the CDE Desktop update the time in milliseconds or only when I do the date command?
And do I have to copy and paste the source that you posted into GEDIT and the save it as "datems.c" and then put I have to put this into the /HOME directory?
Thanks alot.
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
Quote:
Originally Posted by as400
So, after this, will my clock on the CDE Desktop update the time in milliseconds
Your clock isn't updating the time, it just displays it.
Quote:
or only when I do the date command?
Same as the above. the date and clock only display the time with one second precision.
Quote:
And do I have to copy and paste the source that you posted into GEDIT and the save it as "datems.c" and then put I have to put this into the /HOME directory?
Yes, in your $HOME directory precisely, then run the gcc command I wrote in a terminal emulator window.
./micro.c
./micro.c: line 6: syntax error near unexpected token `&'
./micro.c: line 6: ` gettimeofday(&tv, NULL);'
This is what the program looks like - I have named it as micro.c:
#include <sys/time.h>
main()
{
char ct[28];
struct timeval tv;
gettimeofday(&tv, NULL);
sprintf(ct, "%s", ctime(&tv.tv_sec));
printf("%19.19s.%06ld %4.4s\n",ct ,tv.tv_usec, &ct[20]);
exit(0);
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.