How do I convert a Unix timestamp into a date?
I used the fstat function to get information about the modification date of a file and it returned a very large number (a unix timestamp). What function converts this into a date?
I am using C
and the bash shell
"ctime" is one reasonable choice.
It takes a "time_t" structure as input and creates
an ascii string of the date.
Consider the following program:
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
int
main(int argc, char* argv[])
{
struct stat buff;
int fd = -1;
if (argc<2 || ((fd = open(argv[1], O_RDONLY)) < 0))
exit(-1);
if (fstat(fd, &buff) < 0)
perror("fstat"), exit(-1);
printf("File '%s', mod time is %s\n",
argv[1],
ctime(&buff.st_mtime));
return 0;
}
This is what it generates:
$ cc s.c
$ a.out /etc/passwd
File '/etc/passwd', mod time is Wed Feb 21 13:28:38 2007
What are some of the advantages of Unix/Linux over windows?
I have to debate why Unix/Linux is better/ more secure than Windows. Any ideas?
This is for my computer security class. We split up into two groups, and my group has to show some of the reasons that Unix based OS's are more secure than Windows.
I disagree that Linux isn't safer than Windows. Windows has a very long history of having HUNDREDS of vulnerabilities every year. It really opened my eyes when I started manualy approving all updates for Windows on my network at work.
Yes Linux has the same problems, but far fewer and are usually fixed FAR more quickly. There are also far more people working on these problems and on feature upgrades.
The question regarding viruses is pretty much the same, as Linux is more hardened against viruses overall. There is something to say though that there would be more rootkits for Linux out there if the average joe/jane use Linux more often.
As far as usability, Ubuntu has gone a long way to making it user friendly. It is also one of the easiest to install, making it a snap to install Ubuntu on your Windows system and letting both Windows and Ubuntu work. You just pick which one you want when you turn on the PC.
I suggest giving it a try. Feel free to message me if you have any Linux questions down the road.
How to improve performance of a Hashtable used in multi threaded Java application running in HP-unix box?
In my multi threaded Java application running in HP-Unix, i have a hastable. The size of the hashtable is not constant. It is populated from oracle DB using a select query once when the application is loaded.Then i parse this hashtable and process for each entry in it. Now, when i have close to 15K entries in this hashtable, the get() is very slow. How to improve this get() functionality.
I don't know what version of Java you are running, but consider ConcurrentHashMap. It was added in Java 1.5, or for older versions of Java, there is a library that contains it. http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html
Also I _highly_ recommend this book: http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601
ConcurrentHashMap allows multiple threads to read simultaneously without blocking which will greatly improve the speed. Older stuff like Hashtable has synchronized on every method, so only a single thread can read at a time. I'm not exactly sure about Hashtable's synchronized implementation, but I believe that is true.
Browse around at the IBM developerworks site I'm including the link to and you'll find some great articles on this topic.
Whats the difference between 'Windows XP' and Unix as far as an ordinary home user is concerned?
Why do they say Unix is better than windows? What do they mean when they say 'its more stable'?
the above answers tut tut you have not got a clue what your talking about.. if you don't know the proper answer then don't answer questions. you give the wrong answer by doing so… my advice is do your research before answering…
Microsoft Windows any version is proprietor software that is designed by MS it will not communicate with other operating systems or software … you have to pay for MS operating systems and application software. and once you are running windows your stuck with Microsoft and all their software at a high price
on the other hand Linux and Solaris unix are free with all free application software.. it is just the same as windows, point and click but with indifferent file names it is more secure, and faster, and far superior