This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 请教unix shell 高手,看看下面的程序,为什么 mv 文件的部分被执行了两次。
-blackswan(uglyduck);
2005-4-17
{1481}
(#2245120@0)
-
你是说执行了三次吗?是顺序移动啊。最旧的永远是第三个。
-linmeimei(冰雪林妹妹);
2005-4-17
(#2245217@0)
-
不是,执行的结果是:/u06/export/ 是空
/u06/export/day_1 是当天备份的文件
/u06/export/day_2 是空
/u06/export/day_3 是前一天备份的文件
好像是mv 的部分执行了两次
-blackswan(uglyduck);
2005-4-17
{143}
(#2245427@0)
-
你的意思是不是mv /u06/export/day_2/fullexp_wacarc.dmp.Z /u06/export/day_3 这句话还没有执行完,已经把下面一句也执行了
mv /u06/export/day_1/fullexp_wacarc.dmp.Z /u06/export/day_2
然后看到的day_3是昨天的东西,应该是前天的东西,这样理解对吗?
-vetra(piyupiyu);
2005-4-17
{228}
(#2246261@0)
-
我也不知道是怎么回事,只是猜测. day_2应该是前天的备肥,day_1应该是昨天的备肥,/u06/export/是当天的备份,可是现在中间总有一个空目录,好像备份没完成时,程序由被运行了一次,另外output file如下,请进:Server: xxxxxxx
Job: export_compressed started DATE:050415 (Fri) 04:00:00
Job completed; return code 0 DATE:050415 (Fri) 04:00:10
Job completed; return code 0 DATE:050415 (Fri) 04:00:13
不明白为什么会有2行“Job completed“
-blackswan(uglyduck);
2005-4-18
{228}
(#2246773@0)
-
看着两句话,这个Shell不是你写的啊,我不小心看到了很多我想要的东西,我就是看的懂,懒得写。[ $RC != 0 ] &&cleanup $RC "Export wacarc"
cleanup 0
第一句话,就是if then else 的语句,你的RC执行出来的结果不是0,所以执行了一次cleanup,
第二句话,就是再执行一次。
所以你看到了两次结果。
-vetra(piyupiyu);
2005-4-18
{193}
(#2247042@0)
-
程序不是我写的。我只是不明白,如果第一次RC执行出来的结果不是0, 为什么输出文件中的两次return code 0 , 而不是“Batch Job Failure“
-blackswan(uglyduck);
2005-4-18
(#2247448@0)
-
You need to study "korn shell" programming. It never give you "Batch job failure". The return "0" you see is the status of last executed cmd in that shell script.
-bugfree(BugFree);
2005-4-30
(#2269717@0)
-
另外$RC的值是exp's return code 还是compress's return code? Thanks!
-blackswan(uglyduck);
2005-4-18
(#2247486@0)
-
I did test on my UNIX box, it only returns me one time, either "Job completed" or "Batch Job Failure....."
-vetra(piyupiyu);
2005-4-18
(#2247544@0)
-
I did the test on our dev box, the result is same as yours. Even on prod server, it only occur at some night. not always. :-)
-blackswan(uglyduck);
2005-4-18
(#2247733@0)
-
then you need analyze the difference and narrow down the problem. have fun!
-vetra(piyupiyu);
2005-4-18
(#2247838@0)
-
Let me answer this question. In shell script, the return code is always the last command it executed. The special case is using "exit <val>" to terminate the program, then the return code will be "<val>"
-bugfree(BugFree);
2005-4-30
(#2269714@0)
-
This is the aswer: You need to verbose debug your script. to see why "mv /u06/export/day_1/fullexp_wacarc.dmp.Z /u06/export/day_2" failed. This is the procedure:1) ksh -x <script name>, it will verbose all command line and its output.
2) the second way to do it is to change the first line of script from
#!/bin/ksh
to
#!/bin/ksh -x
Good luck !
-bugfree(BugFree);
2005-4-30
{193}
(#2269727@0)