LINUXÊØ»¤½ø³Ì
int Daemon(char* szExecName = NULL)
{
int res = 0;
pid_t pc;
pc = fork();
if(pc < 0)
{
fprintf(stderr,"ERROR_Deamon()_fork(): failed!");
return -1;
}
else if(pc == 0) //sub process
{
}
else if(pc > 0) //parent process
{
fprintf(stderr,"parent process exit!\n");
sleep(2);
exit(0);
}
res = setsid();
if(res == -1)
{
fprintf(stderr,"ERROR_Deamon()_setsid(): errno = %d\n", errno);
return -1;
}
if(pc=fork())
exit(0);//ÊǵÚÒ»×Ó½ø³Ì£¬½áÊøµÚÒ»×Ó½ø³Ì
else if(pc< 0)
exit(1);//forkʧ°Ü£¬Í˳ö
//Êǵڶþ×Ó½ø³Ì£¬¼ÌÐø
//µÚ¶þ×Ó½ø³Ì²»ÔÙÊǻỰ×鳤
// for maybe its path is not current path when run.
char szModulePath[MAX_PATH] = {0};
GetModuleFileName(szExecName, szModulePath, sizeof(szModulePath));
res = chdir(szModulePath);
if(res == -1)
{
fprintf(stderr,"ERROR_Deamon()_chdir(): path = %s, errno = %d\n", szModulePath, errno);
return -1;
}
umask(0);
//for(int i = 0; i < MAXFILE; i++)
// {
//close(i);
//}
return 0;
}Dstlen)
*szTmp = '\0';
return i;
}
1.»ñÈ¡³ÌÐòÔËÐеľø¶Ô·¾¶
int GetModuleFileName(char* sModuleName, char* sModulePath, int nSize)
{
int ret = -1;
char* p = getenv("_");
if(p != NULL && strstr(p, sModuleName) != NULL)
{
realpath(p, sModulePath);
char* p = strrchr(sModulePath, '/');
p[1] = '\0';
ret = 0;
}
else
{
realpath(sModuleName, sModulePath);
char* p = strrchr(sModuleP/');
p[1] = '\0';
ret = 0;
}
return ret;
}
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
1. find ÔÚÌض¨µÄĿ¼ÏÂËÑË÷²¢ÏÔʾָ¶¨Ãû³ÆµÄÎļþºÍĿ¼
ËÑË÷Ò»¶Îʱ¼äÄÚ±»´æÈ¡/±ä¸üµÄÎļþ»òĿ¼
find /home -admin -10 Ê®·ÖÖÓÄÚ´æÈ¡µÄÎļþ»òĿ¼
find /home -atime -10 Ê®¸öСʱÄÚ´æÈ¡µÄÎļþ»òĿ¼
find /home -cmin -10 Ê®·ÖÖÓÄÚ¸ü¸Ä¹ýµÄÎļþ»òĿ¼
find /home -ctime +10 Ê®Ð¡Ê±Ç ......
topÃüÁîÓÃÀ´ÏÔʾϵͳµ±Ç°µÄ½ø³ÌºÍÆäËü×´¿ö£»ËüÊÇÒ»¸ö¶¯Ì¬ÏÔʾ¹ý³Ì£¬¼´Óû§¿Éͨ¹ý°´¼üÀ´²»¶ÏµÄˢе±Ç°µÄ״̬£¬Èç¹ûÔÚǰִ̨ÐÐÃüÁîËû»á¶Àռǰ̨¡£Ö±µ½Óû§ÖÕÖ¹¸Ã³ÌÐòΪֹ¡£±È½Ï׼ȷµÄ˵£¬topÃüÁîÌṩÁËʵʱ¶Ôϵͳ´¦ÀíÆ÷µÄ״̬¼àÊÓ¡£Ëü½«ÏÔʾCPU×îÃô¸ÐµÄÈÎÎñÁÐ±í¡£¸ÃÃüÁî¿ÉÒÔ°´CPUʹÓã¬ÄÚ´ÖʹÓ㬺ÍÖ´ÐÐʱ¼ä¶ÔÈÎÎñ½ø ......
1.
²éÕÒJava
ÏîÄ¿ÖУ¬main
·½·¨¶¨ÒåÔÚÄĸöÎļþ
Àï.
¡¡¡¡Çл»µ½ÄãÒª²éÕÒÏîÄ¿µÄĿ¼ÏÂÖ´ÐÐ
¡¡¡¡grep -rlI '\
¡¡¡¡Èç¹ûÄã¾õµÃ×Ô¼º´ò×ֿ죬²»ÅÂÂé·³Ö´ÐÐÈçÏÂÃüÁîÒ²¿ÉÒÔÕÒµ½¸ÃÎļþ
¡¡¡¡find -type f -name *.java -exec grep -l '\
2
¿ìËٵĽ¨Á¢Ò»¸öÎļþ£¬²¢ÊäÈëһЩÄÚÈÝ
¡¡¡¡cat >> filename
£¬ÊäÈëÒ» ......
¸ÐлÔÎÄ×÷Õߣºhttp://blog.csdn.net/thinkerABC/archive/2006/03/11/621817.aspx
¸ÐлתÌûÕßµÄÅŰ棺http://blog.chinaunix.net/u3/101219/showart_2006014.html
ÎÒÃÇͨ³£°ÑһЩ¹«Óú¯Êý
ÖÆ×÷³Éº¯Êý¿â£¬¹©ÆäËü³ÌÐòʹÓá£
º¯Êý¿â·ÖΪ¾²Ì¬¿âºÍ¶¯Ì¬¿âÁ½ÖÖ¡£
¾²Ì¬¿âÔÚ³ÌÐò±àÒëʱ»á±»Á¬½Óµ½Ä¿±ê´úÂëÖУ¬ ......