- 论坛徽章:
- 0
|
本帖最后由 混人天成 于 2012-09-11 21:32 编辑
- use POSIX ;
- sub demonize{
- chdir '/';
- umask 0;
- open STDIN,'/dev/null' || die "can not change the stream of stdin:$!";
- open STDOUT,'>/dev/null' || die "can not change the stream of stdout:$!";
- open STDERR,'>/dev/null' || die "can not change the stream of stderr:$!";
- defined ($pid=fork) || die "can not fork a process:$!";
- exit if $pid;
- setsid || die "can not create session:$!";
- }
- &demonize;
- open LOG,">>/dev02/ycq/test/log" ||die "can not open file:$!";
- my $num=0;
- while(1){
- $num ++;
- # system("/dev02/ycq/test/echo.sh");
- # system("echo /dev02/ycq/test/write.pl");
- # system("perl /dev02/ycq/test/echo.sh");
- print LOG "$num\n";
- sleep 1;
- }
复制代码 这里为什么不能实现向log中写入信息?求指导!
I GOT IT.
输出存在缓冲! |
|