R Quick Tip: Shutdown Windows after Script Has Finished

May 21, 2013
By

(This article was first published on theBioBucket*, and kindly contributed to R-bloggers)

Quite often I have long procedures running and want to do this over night. However, my computer would still be running all night after the script has finished. This is easily circumvented by the following lines that I put at the end of such a script:

# set working dir
# setwd("C:/Users/Kay/Desktop")

# long procedure:
for(i in 1:1e+5) {cat(i); cat("\n..................\n")}

d <- "something"

# save history
savehistory()

# and worspace
save.image()

# then shutdown after 240 s
system("C:/Windows/system32/shutdown.exe -f -s -t 240")

# this would abort the shutdown:
# system("C:/Windows/system32/shutdown.exe -a")

To leave a comment for the author, please follow the link and comment on his blog: theBioBucket*.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.