Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

R Quick Tip: Shutdown Windows after Script Has Finished

DZone's Guide to

R Quick Tip: Shutdown Windows after Script Has Finished

· Big Data Zone ·
Free Resource

The open source HPCC Systems platform is a proven, easy to use solution for managing data at scale. Visit our Easy Guide to learn more about this completely free platform, test drive some code in the online Playground, and get started today.

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
# 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")

Managing data at scale doesn’t have to be hard. Find out how the completely free, open source HPCC Systems platform makes it easier to update, easier to program, easier to integrate data, and easier to manage clusters. Download and get started today.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}