- 论坛徽章:
- 0
|
/*******************************************
** Filename: ie.c
** Function:
** 貌似linux已经有该实现,不记得了,自己做个
** 间隔执行某命令,还可改进
********************************************
#include
#include
#include
#include
#define USAGE \
"usage: %s \n"
int main(int argc, char ** argv)
{
char buf[1024]; /* the longest command 1024 bytes*/
int len = 0; /* len of command */
int tlen = 0;
int ie = 0;
int i;
if (argc
ie=atoi(argv[1]);
/* faint for atoi not check error, do it myself */
if (0 == ie)
{
printf("your
memset(buf, 0, 1024);
/* show time before exec */
strncat(buf,"echo; date; ", 13);
len = strlen(buf);
for (i=2; i
// printf("%s", buf);
// getchar();
while (1)
{
system(buf);
sleep(ie);
}
return 0;
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/28158/showart_213401.html |
|