Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linuxϵÄdeamon½ø³Ì

Éè¼ÆÒ»¸ölinuxϵÄdeamon½ø³Ì£¬¹Ø¼üÖ»Óм¸¸ö£º
1.forkÁ½´Î¡£
2.forkµÚÒ»´ÎºÍµÚ¶þ´ÎÖ®¼ä³ÉΪ½ø³Ì×éÍ·¡£
3.¸Ä±ä¹¤×÷Ŀ¼¡£
4.ºöÂÔÐźš£
5.ÉèÖöÁдÑÚÂë¡£
Ò»ÏÂÊÇÒ»¸ö´ÓÍøÂçËѼ¯µ½µÄÀý³Ì£¬·Ç³£ºÃµÄÑÝʾÁËÉÏÊöÒªµã£¬´æ´Ë±¸Íü¡£
#include
#include
#include
#include
void main(int argc, char ** argv)
{
time_t now;
int childpid, fd, fdtablesize;
int error, in, out;
/*ºöÂÔÖÕ¶Ë I/OÐźÅ,STOPÐźÅ*/
signal(SIGTTOU,SIG_IGN);
signal(SIGTTIN,SIG_IGN);
signal(SIGTSTP,SIG_IGN);
signal(SIGHUP,SIG_IGN);
/*¸¸½ø³ÌÍ˳ö£¬³ÌÐò½øÈëºǫ́ÔËÐÐ*/
if( fork()!=0 )
{
exit(1);
}
if( setsid()<0 )
{
exit(1); /*´´½¨Ò»¸öеĻáÒé×é*/
}
/*×Ó½ø³ÌÍ˳ö£¬Ëï½ø³Ìʧȥ¿ØÖÆÖÕ¶ËÁË*/
if( fork()!=0 )
{
exit(1);
}
if( chdir("/tmp")==-1 )
{
exit(1);
}
/*¹Ø±Õ´ò¿ªµÄÎļþÃèÊö·û£¬°üÀ¨±ê×¼ÊäÈë¡¢±ê×¼Êä³öºÍ±ê×¼´íÎóÊä³ö*/
fd=0;
for(fdtablesize=getdtablesize(); fd< fdtablesize;fd++)
{
close(fd);
}
umask(0);/*ÖØÉèÎļþ´´½¨ÑÚÂë*/
signal(SIGCHLD,SIG_IGN);/*ºöÂÔSIGCHLDÐźÅ*/
/*´Ë´¦£¬¿ÉÒÔ×ö×Ô¼ºÏë×öµÄ·þÎñÀý³Ì´úÂë¡£Ò»°ãÊÇÒ»¸öËÀÑ­»·£¬Èç¹ûÒª¿ÉÒÔ¿ØÖƵÄÍ˳öµÄ»°£¬¿ÉÒÔÉèÖûñÈ¡Ðźš£ÏÂÃæÊ¾ÀýÒ»ÏÂÒ»¸öдlogµÄÀý³Ì
*/
/*дlog£¬²âÊÔ½á¹û*/
syslog(LOG_USER|LOG_INFO,"ÊØ»¤½ø³Ì²âÊÔ£¡\n");
while(1)
{
time(&now);
syslog(LOG_USER|LOG_INFO,"µ±Ç°Ê±¼ä£º\t%s\t\t\n",ctime(&now));
sleep(6);
}
}
ÉÏÊö³ÌÐòÔÚgcc4.0.1ϱàÒëͨ¹ý£¬ÔÚfc4-2.6.11ÏÂÎȶ¨ÔËÐС£
syslog½«Á¬½ÓsyslogdÕâ¸ö·þÎñ£¬ÔÚ/var/log/messageÕâ¸öÎļþÀïÃæÊä³öÏûÏ¢£¬ËùÒÔÐèÒªÆô¶¯syslogd·þÎñ¡£·ñÔòÔÚ/var/log/messageÕâ¸öÎļþÀïÃæ²»»áÓÐÏÔʾ¡£


Ïà¹ØÎĵµ£º

linuxÆô¶¯¹ý³ÌdzÎö(3)


ÕâÊDZ¾ÎĵõÚÈý²¿·Ö,ÔÚǰÁ½²¿·ÖÖÐ,ÎÒÒѾ­½²ÊöÁËLinux²Ù×÷ϵͳÊÇÈçºÎ±»»úÆ÷bootµ½,²¢ÇÒloadµ½Öƶ¨µÄÄÚ´æµØÖ·µÄ.ÎÒÃǽ«¼ÌÐøµÚ¶þ²¿·ÖµÄÄÚ
ÈÝ,¿´¿´²Ù×÷ϵͳÔÚÍê³ÉÁËbootsect.sºÍsetup.sµÄÔËÐкó,ÔÚhead.sÖÐ×öÁËЩʲô.
ÈÃÎÒÃÇ»ØÒäÒ»ÏÂ,ÔÚsetup.sÖÐ,ÎÒÃǰÑÕû¸ösystemÄ£¿é´ÓµØÖ·0x10000³öÍùÏÂÒÆ¶¯ÁË0x10000µÄ¾àÀë,Ò²¾ÍÊÇ˵,ÏÖ ......

Linux 2.6.19.x Äں˱àÒëÅäÖÃÑ¡Ïî¼ò½é

°æÈ¨ÉùÃ÷
±¾ÎÄ×÷ÕßÊÇһλ×ÔÓÉÈí¼þ°®ºÃÕߣ¬ËùÒÔ±¾ÎÄËäÈ»²»ÊÇÈí¼þ£¬µ«ÊDZ¾×Å GPL µÄ¾«Éñ·¢²¼¡£ÈκÎÈ˶¼¿ÉÒÔ×ÔÓÉʹÓá¢×ªÔØ¡¢¸´ÖƺÍÔÙ·Ö·¢£¬µ«±ØÐë±£Áô×÷ÕßÊðÃû£¬Ò಻µÃ¶ÔÉùÃ÷ÖеÄÈκÎÌõ¿î×÷ÈκÎÐÎʽµÄÐ޸ģ¬Ò²²»µÃ¸½¼ÓÈÎºÎÆäËüÌõ¼þ¡£Äú¿ÉÒÔ×ÔÓÉÁ´½Ó¡¢ÏÂÔØ¡¢´«²¥´ËÎĵµ£¬µ«Ç°ÌáÊDZØÐ뱣֤ȫÎÄÍêÕû×ªÔØ£¬°üÀ¨ÍêÕûµÄ°æÈ¨ÐÅÏ¢ºÍ× ......

linux¹ÒÔØÐÂÓ²ÅÌ

fdisk -l ÃüÁî¿´µ±Ç°´ÅÅÌÐÅÏ¢
[root@roswell root]# fdisk /dev/sdb
Command (m for help): m  --´òÓ¡¸ÃÃüÁîµÄ²ÎÊý¹¦ÄÜÁбí
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibil ......

±¾ÎĽ²ÊöÁËLinuxÃüÁîÐÐÐÞ¸ÄIP¡¢Íø¹Ø¡¢DNSµÄ·½·¨

·½Ê½Ò»£º
ifconfig eth0 192.168.1.18 netmask 255.255.255.0
˵Ã÷£º¸ÃÖÖ·½Ê½¿ÉÒÔʹ¸Ä±ä¼´Ê±ÉúЧ£¬ÖØÆôºó»á»Ö¸´ÎªÔ­À´µÄIP
·½Ê½¶þ£º
vi /etc/sysconfig/network-scripts/ifcfg-eth0
˵Ã÷£º¸Ã·½Ê½ÒªÖØÆôºóÉúЧ£¬ÇÒÊÇÓÀ¾ÃµÄ
Èç¹ûÒªÁ¢¼´¸ü¸ÄÇÒÓÀ¾ÃÉúЧ£¬¾ÍÖ»ÄÜÒÔÉÏÁ½ÖÖ·½Ê½Í¬Ê±Ê¹ÓÃÁË¡£
ÒÔÉÏÊÇͨ¹ýlinuxÃüÁîÐÐÐÞ¸ÄIPµÄ· ......

Linux´ÅÅÌ´æ´¢Çø¹ÜÀíµÄÉîÈë½âÎö

Linux´ÅÅÌ´æ´¢Çø¹ÜÀíËãµÄÉÏÒ»¸ö¼¼ÇÉ£¬ºÜ¶àÅóÓÑÔÚÕâÉÏÃæ³£³£ÎÊÎÒ£¬½ñÌìÎҾͰÑÕâ·½ÃæµÄ¶«Î÷»ã×Üһϣ¬´ÓLinuxÌØÓеĽ»»»·ÖÇøµÄÔ­Àí¿ªÊ¼½éÉÜLinux´ÅÅÌ´æ´¢Çø¹ÜÀíµÄÔ­Àí¼°¼¼ÇÉ¡£
Linux´ÅÅÌ´æ´¢Çø¹ÜÀíÔ­ÀíÆª
1. ½»»»¿Õ¼äÊÇʲô
Linux ÖÐµÄ ½»»»¿Õ¼ä£¨Swap space£© ÔÚÎïÀíÄڴ棨RAM£©±»³äÂúʱ±»Ê¹Óá£Èç¹ûϵͳÐèÒª¸ü¶àµÄÄÚ´æ×Ê ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ