Timed exit from a shell command

I have a shell script to generate two types of reports. Each report is generated by executing a Sweave script and then compiling a PDF out of the resulting tex file.

eval "R CMD Sweave Weekly.Rnw"
eval "pdflatex Weekly.tex"
eval "R CMD Sweave Daily.Rnw"
eval "pdflatex Daily.tex"

For instance, if there is an error when executing 'R CMD Sweave Weekly.Rnw', it exits but still generates a tex file (which I have checked cannot be stopped) and this tex file would not compile correctly in pdflatex ie 'pdflatex Weekly.tex' command would hang and the shell script will not move to the next 'R CMD Sweave Daily.Rnw'.

Now, my question: If I know that a certain shell command should not take more 30 secs, is there a way to induce a timed exit from that command (assuming it hung) after say a couple minutes (or some arbitrary time lapse)? Alternatively, is there a way to force shutdown a latex engine after it encounters errors when compiling a tex file?

Thanks.


使用pdflatex -halt-on-error阻止pdflatex提出问题。


请参阅R.utils::evalWithTimeoutsetTimeLimit - 这些操作可以中断命令,shell或其他方式,我相信,只要用户中断了超时,并且该命令可以被用户中断。


Or, if that pdflatex is being called from R CMD check , and you don't know how to pass arguments to pdflatex, and you are using Windows, then an alternative is :

  • Start->Programs->MikTex 2.9->Maintenance (Admin)->Settings (Admin)
  • and then :

  • Click Refresh FNDB
  • Click Update Formats
  • Change Install missing packages on-the-fly to No
  • This should fix the R CMD check appears to hang error on "checking re-building of vignette PDFs ..." or "checking PDF version of manual ..." problem.

    链接地址: http://www.djcxy.com/p/33438.html

    上一篇: 在RStudio中编译.rnw文件中的PDF会在getSymbols()函数中出错

    下一篇: 从shell命令定时退出