linux»ñȡϵͳʱ¼ä
1.ʱ¼ä±íʾ
ÔÚ³ÌÐòµ±ÖÐ,ÎÒÃǾ³£ÒªÊä³öϵͳµ±Ç°µÄʱ¼ä,±ÈÈçÎÒÃÇʹÓÃdateÃüÁîµÄÊä³ö½á¹û¡£Õâ¸öʱºòÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæÁ½¸öº¯Êý
time_t time(time_t *tloc); //ʱ¼ä¾«¶ÈΪÃë
char *ctime(const time_t *clock); //½«ÃëÊýת»¯Îª×Ö·û´®
timeº¯Êý·µ»Ø´Ó1970Äê1ÔÂ1ÈÕ0µãÒÔÀ´µÄÃëÊý[×¢Ò⣬´Ëº¯Êý·µ»ØµÄʱ¼ä¾«¶ÈÊÇ“Ãë”]¡£´æ´¢ÔÚtime_t ½á¹¹Ö®ÖС£²»¹ýÕâ¸öº¯ÊýµÄ·µ»ØÖµ¶ÔÓÚÎÒÃÇÀ´ËµÃ»ÓÐʲôʵ¼ÊÒâÒå¡£Õâ¸öʱºòÎÒÃÇʹÓõڶþ¸öº¯Êý½«ÃëÊýת»¯Îª×Ö·û´®¡£Õâ¸öº¯ÊýµÄ·µ»ØÀàÐÍÊǹ̶¨µÄ:Ò»¸ö¿ÉÄÜֵΪ¡£ thu dec 7 14:58:59 2000 Õâ¸ö×Ö·û´®µÄ³¤¶ÈÊǹ̶¨µÄΪ26
time_tÀàÐÍʵ¼ÊÉÏÊÇÓÉtypedef¶¨ÒåµÄ£¬²¢²»ÊÇÒ»¸öÐÂÀàÐÍ£¬¶ÔÓÚ¶àÊýϵͳÀ´Ëµ£¬time_t¾ÍÊÇlong£¬¾ßÌå×Ô¼ºÊ¹ÓõÄϵͳÊÇÓÉÄÄÖÖÀàÐÍÅÉÉúµÄ£¬¿ÉÒÔÔÚtime.hÍ·ÎļþÀïÓÃtime_t×÷ΪÌõ¼þ²éÒ»²é¾ÍÖªµÀÁË¡£
ÀàËƵģ¬size_tÒ²ÊÇͬÑùµÄµÀÀí¡£
ÁíÍ⣺
struct tm * gmtime(const time_t *timer);
gmtime()º¯ÊýÊǽ«ÈÕÀúʱ¼äת»¯ÎªÊÀ½ç±ê׼ʱ¼ä£¨¼´¸ñÁÖÄáÖÎʱ¼ä£©£¬²¢·µ»ØÒ»¸ötm½á¹¹ÌåÀ´±£´æÕâ¸öʱ¼ä
struct tm * localtime(const time_t * timer);
localtime()º¯ÊýÊǽ«ÈÕÀúʱ¼äת»¯Îª±¾µØʱ¼ä
ʾÀý´úÂ룺
#include <time.h> //×¢£º²»ÊÇ<sys/time.h> ·ñÔò±àÒë²»±¨´í£¬µ«ÔËÐб¨¶Î´íÎó
#include <stdio.h>
int main()
{
time_t now;
now = time(NULL);
printf("%s", ctime(&now));
return 0;
}
Êä³ö£º
Tue Jun 26 16:29:18 2007
Ö¸¶¨Ê±¼äµÄ·½·¨£º
#include "time.h"
#include "stdio.h"
#include "stdlib.h"
int main(void)
{
struct tm t; //¶¨Òåtmʱ¼ä½á¹¹£¬ÓÃÀ´´æ´¢Ê±¼ä¸ñʽµÄÊý¾ÝÐÅÏ¢
time_t t_of_day; //¶¨Òåtime_tʱ¼ä½á¹¹
t.tm_year=2006-1900;//ÒÔ1900ÄêΪ±ê×¼¼ÆËãʱ¼ä
t.tm_mon=6; //Ϊ½á¹¹Ìå³ÉÔ±¸³Öµ
t.tm_mday=1;
t.tm_hour=0;
t.tm_min=0;
t.tm_sec=1;
t.tm_isdst=0;
t_of_day=mktime(&t);//ʹÓÃm
Ïà¹ØÎĵµ£º
ʹÓÃselectº¯Êý¿ÉÒÔÒÔ·Ç×èÈûµÄ·½Ê½ºÍ¶à¸ösocketͨÐÅ¡£³ÌÐòÖ»ÊÇÑÝʾselectº¯ÊýµÄʹÓ㬹¦Äܷdz£¼òµ¥£¬¼´Ê¹Ä³¸öÁ¬½Ó¹Ø±ÕÒÔºóÒ²²»»áÐ޸ĵ±Ç°Á¬½ÓÊý£¬Á¬½ÓÊý´ïµ½×î´óÖµºó»áÖÕÖ¹³ÌÐò¡£
1. ³ÌÐòʹÓÃÁËÒ»¸öÊý×éfd_A£¬Í¨ÐÅ¿ªÊ¼ºó°ÑÐèҪͨÐŵĶà¸ösocketÃèÊö·û¶¼·ÅÈë´ËÊý×é¡£
2. Ê×ÏÈÉú³ÉÒ»¸ö½Ðsock_fdµÄsocketÃèÊö·û£¬ÓÃÓÚ¼àÌý¶Ë¿ ......
linuxϾ²Ì¬¿âǶÌ×ʹÓÃ
Ç°ÌáÊÇÄã»áÔÚlinuxϵ÷Óþ²Ì¬¿âºÍ¶¯Ì¬¿âºÍMakfile±à³Ì(µ±È»²»»áMakfileÖ±½ÓÔÚÖÕ¶ËÃüÁîÒ²³É)
±¾ÀýÊÇÏÈÓÉStringLen.h,StringLen.cÉú³Élibrak.a
È»ºóÀûÓÃStringLen2.h£¬StringLen2.²¢µ÷ÓÃlibrak.aÉú³Élibrak2.a
×îºóÀûÓÃStringLen3.h,StringLen3.cµ÷ÓÃlibrak2.a Éú³Élibrak3.so
------------------ ......
RPM ÊÇ RedHat Package Manager µÄËõд£¬Èí¼þ°ü¹ÜÀí¹¤¾ß¡£
RPMÎļþÔÚLINUXϵͳÖеݲװ×îΪ¼ò±ã¡£
LinuxÈí¼þ°ü£¬³£¼ûµÄ¸ñʽ°üÀ¨ÓÐrpm,deb,tar,gz,tgz,zip,bz2µÈµÈ¡£¼¸ºõÿ¸ölinuxÈí¼þ¶¼»áÌṩtarµÄ¸ñʽµÄÈí¼þ°ü£¬
ÒòΪÕâÖÖ¸ñʽµÄÈí¼þ°üÈκΰ汾µÄlinux¶¼Ö§³Ö£¬ËùÒÔÖÁÉÙÒªÁ˽âtarºÍrpmµÃʹÓ÷½·¨¡£
rpm¿ÉνÊÇRedhat¹«Ë¾µ ......
RHEL5´î½¨DNS·þÎñÆ÷ʵÏÖÃû³Æ½âÎö Èý
£¨¶þ£©named.confÎļþ˵Ã÷£º
´ËÎļþÐèÓû§×Ô¼º´´½¨£¬¿É´Ó/usr/share/doc/bind-9.3.3/sample/etcÖи´ÖƵ½/var/named/chroot/etc/Ŀ¼ÏÂ
// Sample named.conf BIND DNS server 'named' configuration file
// for the Red Hat BIND distribution.
// See the BIND ......
#!/bin/bash
cpu=`top -b -n 1 | grep -w Cpu | awk '{print$5}'| awk -F '%' '{printf"%d",$1}'`
if [ $cpu -le 50 ]
then
echo "cpu: $((100 - cpu))%" > test.txt
mail -s "·þÎñÆ÷½ô¼±, CPUÕ¼ÓÃÂʹý¸ß£¡" yourmail@domail.com < test.txt
fi
mem=`top -b -n 1 | grep -w Me ......