forked from prokulski/Mundial2018_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_cron.R
82 lines (76 loc) · 2.81 KB
/
generate_cron.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# generator wpisów do CRONa dla meczy rozgrywających się pojedynczo (jeden mecz o jednej porze)
library(tidyverse)
library(lubridate)
ttable <- read.table(text = "
19 14:00 COL JPN
19 17:00 POL SEN
19 20:00 RUS EGY
20 14:00 POR MAR
20 17:00 URU KSA
20 20:00 IRN ESP
21 14:00 DEN AUS
21 17:00 FRA PER
21 20:00 ARG CRO
22 14:00 BRA CRC
22 17:00 NGA ISL
22 20:00 SRB SUI
23 14:00 BEL TUN
23 17:00 KOR MEX
23 20:00 GER SWE
24 14:00 ENG PAN
24 17:00 JPN SEN
24 20:00 POL COL
") %>%
set_names(c("day", "hour", "teama", "teamb"))
for(i in 1:nrow(ttable)) {
# # capture
# 45 13 19 6 * Rscript /home/lemur/RProjects/Mundial2018_twitter_stream/capture_stream.R 16:15 COLJPN
# # post
# 50 14 19 6 * Rscript /home/lemur/RProjects/Mundial2018_twitter_stream/analyze_stream.R 1 COL JPN
# 2 16 19 6 * Rscript /home/lemur/RProjects/Mundial2018_twitter_stream/analyze_stream.R 1 COL JPN
# 17 16 19 6 * Rscript /home/lemur/RProjects/Mundial2018_twitter_stream/polskie_mecze.R 1 eng COL JPN
time <- ymd_hm(paste0("2018-06-", as.character(ttable[i, "day"]), " " ,
as.character(ttable[i, "hour"])))
teamA <- as.character(ttable[i, "teama"])
teamB <- as.character(ttable[i, "teamb"])
# coment1
cat(paste0("# ", teamA, " ", teamB, " ", format(time, "%Y-%m-%d %H:%M"), "\n"))
# collect
cat("# capture\n")
cat(paste0(minute(time - minutes(15)), " ",
hour(time - minutes(15)), " ",
day(time), " ",
month(time), " ",
wday(time, week_start = 1), " ",
"Rscript /home/lemur/RProjects/Mundial2018_twitter_stream/capture_stream.R ",
hour(time + minutes(135)), ":",
minute(time + minutes(135)), " ",
teamA, teamB, "\n"))
# post
cat("# post\n")
# half
cat(paste0(minute(time + minutes(55)), " ",
hour(time + minutes(55)), " ",
day(time), " ",
month(time), " ",
wday(time, week_start = 1), " ",
"Rscript /home/lemur/RProjects/Mundial2018_twitter_stream/analyze_stream.R 1 ",
teamA, " " , teamB, "\n"))
# end
cat(paste0(minute(time + minutes(124)), " ",
hour(time + minutes(124)), " ",
day(time), " ",
month(time), " ",
wday(time, week_start = 1), " ",
"Rscript /home/lemur/RProjects/Mundial2018_twitter_stream/analyze_stream.R 1 ",
teamA, " " , teamB, "\n"))
# f-words
cat(paste0(minute(time + minutes(137)), " ",
hour(time + minutes(137)), " ",
day(time), " ",
month(time), " ",
wday(time, week_start = 1), " ",
"Rscript /home/lemur/RProjects/Mundial2018_twitter_stream/polskie_mecze.R 1 ",
ifelse(teamA == "POL" | teamB == "POL", "pl ", "eng "),
teamA, " " , teamB, "\n\n"))
}