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;
}
Ïà¹ØÎĵµ£º
1. find ÔÚÌض¨µÄĿ¼ÏÂËÑË÷²¢ÏÔʾָ¶¨Ãû³ÆµÄÎļþºÍĿ¼
ËÑË÷Ò»¶Îʱ¼äÄÚ±»´æÈ¡/±ä¸üµÄÎļþ»òĿ¼
find /home -admin -10 Ê®·ÖÖÓÄÚ´æÈ¡µÄÎļþ»òĿ¼
find /home -atime -10 Ê®¸öСʱÄÚ´æÈ¡µÄÎļþ»òĿ¼
find /home -cmin -10 Ê®·ÖÖÓÄÚ¸ü¸Ä¹ýµÄÎļþ»òĿ¼
find /home -ctime +10 Ê®Ð¡Ê±Ç ......
²âÁ¿Íø¿¨µÄÍøÂçÁ÷Á¿£¬linuxÏÂÓÐÁ½¿îС¹¤¾ßnloadºÍiftop
ÏÂÔØÔ´Îļþºóconfigue && make && make install
¸öÈ˱ȽÏϲ»¶iftop£¬ËüÄܶ¯Ì¬µÄÓüòµ¥µÄASCͼ±êʶÍø¿¨µ±Ç°Á÷Á¿
Ê×ÐÐÊÇÍøÂçÁ÷Á¿¿Ì¶È£¬
ÖмäÊÇÓëÆäËü»úÆ÷µÄÁ÷Á¿£¬Óиö°×µ×µÄbarÖ±¹ÛµÄ±êʶÁ÷Á¿±ä»¯£¬ºóÈýÁÐÊý¾Ý·Ö±ð±íʾ£º
1. preceding 2 seco ......
Ãû³Æ£ºcp
ʹÓÃȨÏÞ£ºËùÓÐʹÓÃÕß
ʹÓ÷½Ê½£º
cp [options] source dest
cp [options] source... directory
˵Ã÷£º½«Ò»¸öµµ°¸¿½±´ÖÁÁíÒ»µµ°¸£¬»ò½«Êý¸öµµ°¸¿½±´ÖÁÁíһĿ¼¡£
°Ñ¼Æ
-a ¾¡¿ÉÄܽ«µµ°¸×´Ì¬¡¢È¨ÏÞµÈ×ÊÁ϶¼ÕÕÔ×´ÓèÒÔ¸´ÖÆ¡£
-r Èô source Öк¬ÓÐĿ¼Ãû£¬Ôò½«Ä¿Â¼ÏÂÖ®µµ°¸Òà½ÔÒÀÐò¿½±´ÖÁÄ¿µÄµØ¡£
-f ÈôÄ¿µÄµ ......
LinuxÉ豸Çý¶¯
µÚÒ»Õ É豸Çý¶¯¼ò½é
Çý¶¯³ÌÐòµÄ½ÇÉ«ÊÇÌṩ»úÖÆ£¬¶ø²»ÊDzßÂÔ¡£
±àдÄں˴úÂëÀ´´æÈ¡Ó²¼þ£¬µ«ÊDz»ÄÜÇ¿¼ÓÌرðµÄ²ßÂÔ¸øÓû§(Ö»ÐèÒª±íÏÖ³öÓ²¼þµÄ×î»ù±¾µÄ¹¦ÄÜ£¬ÈçºÎʹÓÃÕâЩ¹¦ÄÜÓÖÓû§×Ô¼ºÑ¡Ôñ)
¶Ô²ßÂÔ͸Ã÷µÄÇý¶¯ÌØÕ÷£ºÖ§³Öͬ²½ºÍÒì²½²Ù×÷¡¢¿ÉÒÔ¶à´Î´ò¿ª¡¢ÀûÓÃÓ²¼þÈ«²¿ÄÜÁ¦¡¢Ã»ÓÐÈí¼þ²ãÌṩ²ßÂÔÏà¹Ø ......