Arjun
Arjun

Reputation: 157

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 i.e. '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?

Upvotes: 3

Views: 366

Answers (3)

Matt Dowle
Matt Dowle

Reputation: 59602

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.

Upvotes: 0

Iterator
Iterator

Reputation: 20560

See R.utils::evalWithTimeout or setTimeLimit - these can interrupt commands, shell or otherwise, I believe, when a timeout is reached and as long as the command can be interrupted by the user.

Upvotes: 2

Simon Urbanek
Simon Urbanek

Reputation: 13932

Use pdflatex -halt-on-error to stop pdflatex from asking questions.

Upvotes: 3

Related Questions