Если файл содержит обратную косую черту (обычно пути), вы можете попробовать что-то вроде этого:
sed -i -- 's,<path1>,<path2>,g' *
ex:
sed -i -- 's,/foo/bar,/new/foo/bar,g' *.sh (in all shell scripts available)
Проще всего использовать Task Scheduler для Windows или задание cron в Linux. Там вы можете указать команду или программу, которые должны запускаться в определенное вами время. Я определенно не рекомендую R-скрипт вроде:
time_to_run = as.POSIXct("2012-04-18 17:25:40")
while(TRUE) {
Sys.sleep(1)
if(Sys.time == time_to_run) {
## run some code
}
}
Если вы каким-то образом не можете использовать службу заданий cron и должны планировать внутри R, следующий R-код показывает, как подождать определенное количество времени, чтобы выполнить в заданное целевое время.
stop.date.time.1 <- as.POSIXct("2012-12-20 13:45:00 EST") # time of last afternoon execution.
stop.date.time.2 <- as.POSIXct("2012-12-20 7:45:00 EST") # time of last morning execution.
NOW <- Sys.time() # the current time
lapse.time <- 24 * 60 * 60 # A day's worth of time in Seconds
all.exec.times.1 <- seq(stop.date.time.1, NOW, -lapse.time) # all of afternoon execution times.
all.exec.times.2 <- seq(stop.date.time.2, NOW, -lapse.time) # all of morning execution times.
all.exec.times <- sort(c(all.exec.times.1, all.exec.times.2)) # combine all times and sort from recent to future
cat("To execute your code at the following times:\n"); print(all.exec.times)
for (i in seq(length(all.exec.times))) { # for each target time in the sequence
## How long do I have to wait for the next execution from Now.
wait.time <- difftime(Sys.time(), all.exec.times[i], units="secs") # calc difference in seconds.
cat("Waiting for", wait.time, "seconds before next execution\n")
if (wait.time > 0) {
Sys.sleep(wait.time) # Wait from Now until the target time arrives (for "wait.time" seconds)
{
## Put your execution code or function call here
}
}
}
else { print("I'm still waiting...\n")}
:-) – Carl Witthoft 18 April 2012 в 13:04