WEBVTT

1
00:00.000 --> 00:04.640
So in the previous video, we learned how we could do task scheduling, utilizing

2
00:04.640 --> 00:06.320
the @ command via

3
00:06.320 --> 00:10.320
answerable that was using the @ module. What we now want to do though, is we

4
00:10.320 --> 00:10.960
want to learn how

5
00:10.960 --> 00:15.940
we can invoke task scheduling on a repeated basis because recall the @ command

6
00:15.940 --> 00:17.280
is for a one time

7
00:17.280 --> 00:22.030
command in the future. If we want to do the same type of jobs repetitively, i.e

8
00:22.030 --> 00:23.360
. maybe once every

9
00:23.360 --> 00:27.580
hour, once a week, that type of thing, we want to use the cron utility. So that

10
00:27.580 --> 00:28.560
really is the big

11
00:28.560 --> 00:33.320
advantage of cron. We can get that same type of scheduling, but as i say, it's
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

11
00:28.560 --> 00:33.320
advantage of cron. We can get that same type of scheduling, but as i say, it's

12
00:33.320 --> 00:34.240
not a one time

13
00:34.240 --> 00:39.280
thing. So let's just do a very brief refresh on cron before we dive into the

14
00:39.280 --> 00:40.240
module so that we're

15
00:40.240 --> 00:43.870
very clear on what we're trying to do here. Now one of the main configuration

16
00:43.870 --> 00:45.360
files for cron is the

17
00:45.360 --> 00:50.200
@8cron tab file and it is in this particular file that you can specify cron

18
00:50.200 --> 00:51.600
jobs on a system wide

19
00:51.600 --> 00:56.470
basis. Now understand that we do have such a thing as a user specific cron job,

20
00:56.470 --> 00:57.680
but for the purposes

21
00:57.680 --> 01:01.730
of this particular video, we don't have to rehash all the details around cron.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

21
00:57.680 --> 01:01.730
of this particular video, we don't have to rehash all the details around cron.

22
01:01.730 --> 01:02.320
So like a sale,

23
01:02.320 --> 01:05.840
let's just do a brief recap and then we'll begin looking at the module itself.

24
01:05.840 --> 01:07.040
So if i go in and

25
01:07.040 --> 01:11.910
say it's sudo vim, i'm going to @8cron tab right here and to enter. Check this

26
01:11.910 --> 01:12.640
out right here,

27
01:12.640 --> 01:16.480
here's the format we're looking at. So we have some very important components.

28
01:16.480 --> 01:17.520
The first part here

29
01:17.520 --> 01:22.670
actually denotes the scheduling. You see these five options right here. So the

30
01:22.670 --> 01:23.440
first column here

31
01:23.440 --> 01:27.800
denotes the minutes. The next one is the hour. Then we go with the day of the

32
01:27.800 --> 01:29.200
month, then the month,

33
01:29.200 --> 01:32.640
and then the day of the week. Now when we happen to see the asterisk here, that
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

33
01:29.200 --> 01:32.640
and then the day of the week. Now when we happen to see the asterisk here, that

34
01:32.640 --> 01:33.680
pretty much denotes

35
01:33.680 --> 01:38.520
the value any. Basically it's a wildcard. So inside of here, we can see we have

36
01:38.520 --> 01:39.520
asterisk for

37
01:39.520 --> 01:43.860
every single column. So what does that actually mean? Well it tells us that the

38
01:43.860 --> 01:44.640
job that we want

39
01:44.640 --> 01:48.790
to run executed by the particular user, which is in the next column, the sixth

40
01:48.790 --> 01:49.680
column, and in the

41
01:49.680 --> 01:53.440
seventh column we specify what it is we actually want to do. What is the job we

42
01:53.440 --> 01:54.080
want to happen

43
01:54.080 --> 01:58.370
on this repetitive basis? So this might actually be the root user. And let's

44
01:58.370 --> 01:59.680
just say they want to

45
01:59.680 --> 02:03.530
run the command echo hello. Not exactly the most useful command, just to be
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

45
01:59.680 --> 02:03.530
run the command echo hello. Not exactly the most useful command, just to be

46
02:03.530 --> 02:04.560
repetitively echoing,

47
02:04.560 --> 02:08.360
but nevertheless you get the drift. Now how often do we want the root user to

48
02:08.360 --> 02:08.880
echo this

49
02:08.880 --> 02:13.100
particular command? Well as per the schedule right here, we have five asterisks

50
02:13.100 --> 02:14.240
. So what it means is

51
02:14.240 --> 02:19.220
that that particular command echo hello is going to be ran by the root user

52
02:19.220 --> 02:20.560
every single minute,

53
02:20.560 --> 02:24.930
because you have an asterisk on every single hour of every day of the month on

54
02:24.930 --> 02:26.000
every month

55
02:26.000 --> 02:30.000
and every day of the week. Pretty much it will be running every single minute
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

56
02:30.000 --> 02:31.120
without stop. Now of

57
02:31.120 --> 02:34.930
course we can modify these particular values if we so wish. Say for example if

58
02:34.930 --> 02:36.160
we want to have a

59
02:36.160 --> 02:41.840
task be executed at 20 past 12 in the minute column, we would have the value 20

60
02:41.840 --> 02:42.640
. And then the

61
02:42.640 --> 02:46.550
error column we would have the value 12. And then again we could just continue

62
02:46.550 --> 02:47.920
on with our asterisks

63
02:47.920 --> 02:50.850
that type of thing. Now like I say in the interest of time we're not going to

64
02:50.850 --> 02:51.760
go through all of the

65
02:51.760 --> 02:56.240
permutations and possibilities of scheduling with cron. What I will do though

66
02:56.240 --> 02:57.280
is give you a good

67
02:57.280 --> 03:01.840
little reference here. So if we go to Google and if you type in cron guru this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

67
02:57.280 --> 03:01.840
little reference here. So if we go to Google and if you type in cron guru this

68
03:01.840 --> 03:02.880
is a cron schedule

69
03:02.880 --> 03:06.810
expression generator. So if I click this link here what you can do here is go

70
03:06.810 --> 03:07.680
down to examples.

71
03:07.680 --> 03:11.630
And if I scroll in a little bit here whatever schedule you want to do if you

72
03:11.630 --> 03:12.560
click on one of the

73
03:12.560 --> 03:16.760
options it's going to show you how to convert the schedule that you want into a

74
03:16.760 --> 03:17.920
valid cron job. So

75
03:17.920 --> 03:22.670
say for example we have one here saying every 15 minutes let's click this here.

76
03:22.670 --> 03:23.040
This is the

77
03:23.040 --> 03:27.500
expression we would do we would have the asterisks divided by 15 and then we

78
03:27.500 --> 03:28.800
would have asterisks

79
03:28.800 --> 03:33.260
for the remaining columns. So every single 15 minutes the job would run again
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

79
03:28.800 --> 03:33.260
for the remaining columns. So every single 15 minutes the job would run again

80
03:33.260 --> 03:34.160
we go back. If you

81
03:34.160 --> 03:38.840
wanted to do every Friday at midnight in the case here we have the minute zero

82
03:38.840 --> 03:39.440
and the hour zero

83
03:39.440 --> 03:43.020
for midnight. We don't care the day so we have an asterisk we don't care the

84
03:43.020 --> 03:43.920
month so again we

85
03:43.920 --> 03:47.980
have an asterisk but we do care that it's on a Friday. So in the last column we

86
03:47.980 --> 03:48.800
can specify the

87
03:48.800 --> 03:53.460
keyword fri for Friday. Really good page to use when you're practicing your cr

88
03:53.460 --> 03:54.480
on jobs with that

89
03:54.480 --> 03:58.020
said. How about we go and actually look at the module itself then. So if I just

90
03:58.020 --> 03:58.560
go for the

91
03:58.560 --> 04:02.480
answerable cron module and I click this link here notice unlike the app module
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

91
03:58.560 --> 04:02.480
answerable cron module and I click this link here notice unlike the app module

92
04:02.480 --> 04:03.200
this one is

93
04:03.200 --> 04:07.510
actually built in. Okay so as we can see as per the synopsis this module is

94
04:07.510 --> 04:08.480
used to manage cron

95
04:08.480 --> 04:13.260
tab and environment variable entries. So let's scroll on down a little bit

96
04:13.260 --> 04:14.240
further. Look at this

97
04:14.240 --> 04:18.690
right here we have the day option pretty much just like we saw in the actual cr

98
04:18.690 --> 04:19.600
on tab itself.

99
04:19.600 --> 04:23.830
Notice the default value specified here is an asterisk. So if you don't

100
04:23.830 --> 04:25.520
actually provide a value

101
04:25.520 --> 04:29.160
it's going to be assumed that it will run every day. Now we can see here valid

102
04:29.160 --> 04:30.080
values are things
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

102
04:29.160 --> 04:30.080
values are things

103
04:30.080 --> 04:34.310
like 1 to 31 so that could be say for example the first day of the month or

104
04:34.310 --> 04:35.600
maybe the 10th day of

105
04:35.600 --> 04:39.940
the month that type of thing and we can also do expressions such as everyday

106
04:39.940 --> 04:41.120
divided by 2 so

107
04:41.120 --> 04:45.550
every second day that type of thing. Now scrolling on down. Similarly we see

108
04:45.550 --> 04:47.120
the hour option again

109
04:47.120 --> 04:51.400
a 60 string the valid numbers can be from 0 to 23 that of course makes sense

110
04:51.400 --> 04:52.720
because we have

111
04:52.720 --> 04:58.210
24 hours in a day. So 0 would be at midnight 23 would be 11 p.m. Similarly we

112
04:58.210 --> 04:59.520
can use our asterisks

113
04:59.520 --> 05:03.440
and use expressions such as dividing by 2 so every second day or that type of
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

113
04:59.520 --> 05:03.440
and use expressions such as dividing by 2 so every second day or that type of

114
05:03.440 --> 05:04.480
thing. Once again

115
05:04.480 --> 05:09.920
the default value is an asterisk. Now here is an important value. We have the

116
05:09.920 --> 05:11.680
job parameter. This

117
05:11.680 --> 05:15.460
is what we want to use to specify the command that we want to actually execute.

118
05:15.460 --> 05:16.240
So the task that

119
05:16.240 --> 05:19.980
is going to be ran is specified via the job and then we control the frequency

120
05:19.980 --> 05:20.880
of the job runs

121
05:20.880 --> 05:24.610
via the other parameters such as minute and hour that type of thing. And again

122
05:24.610 --> 05:25.680
scrolling on down

123
05:25.680 --> 05:30.080
we have the minute parameter. Once again the options are 0 to 59 of course that
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

123
05:25.680 --> 05:30.080
we have the minute parameter. Once again the options are 0 to 59 of course that

124
05:30.080 --> 05:30.880
makes sense.

125
05:30.880 --> 05:34.640
We have 60 minutes with an hour and again we have the same type of expressions

126
05:34.640 --> 05:35.120
we can do

127
05:35.120 --> 05:39.440
as to x divided by 4 as to divided by 2 that type of thing and the default once

128
05:39.440 --> 05:40.000
again as an

129
05:40.000 --> 05:43.620
asterisk so that we will run every minute unless specified otherwise and of

130
05:43.620 --> 05:45.520
course below again

131
05:45.520 --> 05:49.460
we have the month and it says the valid values run from the first all the way

132
05:49.460 --> 05:50.080
to the 12th.

133
05:50.080 --> 05:53.500
Again that is from January the first month all the way to December the 12th and

134
05:53.500 --> 05:54.240
final month.

135
05:54.240 --> 05:57.760
With the option again to do all of our expressions so no surprises there.

136
05:57.760 --> 06:02.480
Now one thing you'll notice here the name parameter actually is a require
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

136
05:57.760 --> 06:02.480
Now one thing you'll notice here the name parameter actually is a require

137
06:02.480 --> 06:03.840
parameter we need this

138
06:03.840 --> 06:07.630
in order for the module to operate we're going to use this name parameter to

139
06:07.630 --> 06:08.560
give a description

140
06:08.560 --> 06:12.300
of the current tab entry itself or if you so wish the environment variable that

141
06:12.300 --> 06:13.120
has been set.

142
06:13.120 --> 06:16.980
Now one last one that I want to point out to you that is really quite helpful

143
06:16.980 --> 06:18.000
is this option

144
06:18.000 --> 06:23.690
special underscore time this really helps simplify your time specifications so

145
06:23.690 --> 06:24.480
as opposed to having

146
06:24.480 --> 06:29.940
to go through that particular option such as maybe say asterisk 1215 whatever

147
06:29.940 --> 06:30.880
it may be and make
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

147
06:29.940 --> 06:30.880
it may be and make

148
06:30.880 --> 06:35.680
some complex expression that can be very handy if you have to be very precise

149
06:35.680 --> 06:36.720
but in the case of

150
06:36.720 --> 06:41.620
if you just want to do a simple repetitive task such as something daily or

151
06:41.620 --> 06:42.880
something hourly we

152
06:42.880 --> 06:46.460
have these particular keywords to invoke that frequency so we can see we have

153
06:46.460 --> 06:47.440
available options

154
06:47.440 --> 06:51.670
such as annually which is once a year daily once a day hourly every hour

155
06:51.670 --> 06:53.040
monthly for once a month

156
06:53.040 --> 06:57.870
on reboots so when the system reboots as well as weekly and yearly so if we

157
06:57.870 --> 06:58.880
want to have a simple

158
06:58.880 --> 07:02.750
task this can be a really good way to express that job so with that said let's
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

158
06:58.880 --> 07:02.750
task this can be a really good way to express that job so with that said let's

159
07:02.750 --> 07:03.520
get hands on and

160
07:03.520 --> 07:07.510
begin looking at a simple example then now just to highlight the contrast of

161
07:07.510 --> 07:08.720
using cron as opposed

162
07:08.720 --> 07:12.620
to the ad command what I want to do is to provide actual evidence that a

163
07:12.620 --> 07:13.600
particular job

164
07:13.600 --> 07:18.640
happened multiple times so here's an easy way to do this notice when I type the

165
07:18.640 --> 07:19.360
date command we

166
07:19.360 --> 07:23.450
actually get some time date information now if I just say echo and then say

167
07:23.450 --> 07:24.400
dollar sign and then

168
07:24.400 --> 07:28.670
within parentheses I say dates this is going to echo the same command now what

169
07:28.670 --> 07:29.600
I can also do is

170
07:29.600 --> 07:34.580
provide particular formatting here what I can do is I can say dates and then
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

170
07:29.600 --> 07:34.580
provide particular formatting here what I can do is I can say dates and then

171
07:34.580 --> 07:36.880
say percentage h dash

172
07:36.880 --> 07:42.680
percentage m dash percentage capital s now what I get here is I'm actually

173
07:42.680 --> 07:43.840
getting the date but

174
07:43.840 --> 07:48.620
I'm parsing out the hour the minutes and the seconds so if I do this again I'm

175
07:48.620 --> 07:49.680
going to get a different

176
07:49.680 --> 07:53.740
value you see that so I'll just say pseudo vim it's a cron tab from now going

177
07:53.740 --> 07:54.880
to insert mode and

178
07:54.880 --> 07:59.290
I'll just manually say for every single minute I want the answerable user to

179
07:59.290 --> 08:00.400
run the command and
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

179
07:59.290 --> 08:00.400
run the command and

180
08:00.400 --> 08:03.610
just as we saw there echo and then I'll have my quotation marks or then I'll

181
08:03.610 --> 08:04.400
say dollar sign

182
08:04.400 --> 08:08.950
up parentheses date close parentheses and close my quotations and then I'll

183
08:08.950 --> 08:09.920
just append that into

184
08:09.920 --> 08:14.920
a file I'll just call this time test dot txt okay let's just save this if I go

185
08:14.920 --> 08:16.720
into the temp directory

186
08:16.720 --> 08:21.050
and do an ls notice we don't actually have that particular file quite just yet

187
08:21.050 --> 08:22.240
if I check the date

188
08:22.240 --> 08:27.200
in about 13 seconds that is going to change three more seconds if I do a date

189
08:27.200 --> 08:28.400
again now we've passed

190
08:28.400 --> 08:32.010
if I do an ls now we can see we have the time test now what I'm actually going
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

190
08:28.400 --> 08:32.010
if I do an ls now we can see we have the time test now what I'm actually going

191
08:32.010 --> 08:32.720
to do here is

192
08:32.720 --> 08:37.360
cat this file we can see the actual time and I'm going to wait one more minutes

193
08:37.360 --> 08:38.080
because in one more

194
08:38.080 --> 08:43.300
minute the same command should run again and append a new value into the same

195
08:43.300 --> 08:44.640
file thus proving that

196
08:44.640 --> 08:48.810
cron is not just going to run one time only okay so I do a date again now in

197
08:48.810 --> 08:50.400
minute has a lapse again

198
08:50.400 --> 08:54.790
if I do an ls the file is still there but if I cat it again and I enter now we

199
08:54.790 --> 08:56.160
have a second time

200
08:56.160 --> 09:00.520
one minute later the command run again and then one minute time again it's
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

200
08:56.160 --> 09:00.520
one minute later the command run again and then one minute time again it's

201
09:00.520 --> 09:01.680
going to contain the

202
09:01.680 --> 09:05.970
run and run and run so let's use cron to backup let's maybe say the contents of

203
09:05.970 --> 09:06.960
a directory so

204
09:06.960 --> 09:10.930
let's imagine if we go on to our managed devices if we go into the temp

205
09:10.930 --> 09:12.320
directory I would just make

206
09:12.320 --> 09:17.000
a directory called important stuff okay if I cdn to here let's imagine we had

207
09:17.000 --> 09:18.000
some important files

208
09:18.000 --> 09:22.480
let's say touch file one and file number two okay now of course again you would

209
09:22.480 --> 09:23.200
not really have

210
09:23.200 --> 09:26.090
important stuff within the temp directory but nevertheless let's just play

211
09:26.090 --> 09:27.280
along so here we have this

212
09:27.280 --> 09:31.590
particular directory let's do the same thing on our blue box so cdn to temp
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

212
09:27.280 --> 09:31.590
particular directory let's do the same thing on our blue box so cdn to temp

213
09:31.590 --> 09:32.720
again let's make a

214
09:32.720 --> 09:36.580
directory called important stuff we'll cdn to this directory and let's just say

215
09:36.580 --> 09:38.320
there is file one

216
09:38.320 --> 09:42.750
dot txt and let's maybe say we'll also have file two let's maybe give this a

217
09:42.750 --> 09:44.080
JSON extension and

218
09:44.080 --> 09:47.810
let's maybe say file three has a cfg extension whatever it may be just so we've

219
09:47.810 --> 09:48.400
got a little

220
09:48.400 --> 09:52.860
variation so let's imagine that despite being in the temp directory everything

221
09:52.860 --> 09:53.680
within these four

222
09:53.680 --> 09:57.340
those the important stuff we want to be backed up so what we'll do here is we

223
09:57.340 --> 09:58.880
'll go on to our control

224
09:58.880 --> 10:02.560
nodes and we're going to write a simple bash script to perform that action and
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

224
09:58.880 --> 10:02.560
nodes and we're going to write a simple bash script to perform that action and

225
10:02.560 --> 10:03.440
then copy that

226
10:03.440 --> 10:07.430
bash script from the control node onto the respective managed devices where

227
10:07.430 --> 10:08.880
they can be scheduled to

228
10:08.880 --> 10:14.100
run via cron so i'll just create a file called backup dot sh so we'll have our

229
10:14.100 --> 10:15.360
shebang bin bash

230
10:15.360 --> 10:19.680
and i'll specify my source directory and it's going to be in the temp directory

231
10:19.680 --> 10:20.160
and then it's going

232
10:20.160 --> 10:23.760
to be the important stuff directory within and let's just say the backup

233
10:23.760 --> 10:25.440
directory is going to be in

234
10:25.440 --> 10:29.880
the Ansible users home directory and we'll actually have a folder called backup

235
10:29.880 --> 10:31.040
explicitly okay now
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

235
10:29.880 --> 10:31.040
explicitly okay now

236
10:31.040 --> 10:34.290
the actual file name what we're going to do is we're going to use what we just

237
10:34.290 --> 10:35.040
saw before that

238
10:35.040 --> 10:39.390
will be the dollar sign and then the date and what i will do here is i'll say

239
10:39.390 --> 10:40.560
plus percentage

240
10:40.560 --> 10:45.310
h for the hour and then percentage n for the minute and then percentage s for

241
10:45.310 --> 10:46.400
the second again

242
10:46.400 --> 10:49.640
this is not very realistic because what i'm going to do is run this every

243
10:49.640 --> 10:50.800
minute that is far too

244
10:50.800 --> 10:54.100
frequent for a real backup but for the purposes of the video we want to do

245
10:54.100 --> 10:55.280
things very frequently

246
10:55.280 --> 11:01.680
and then i'll just give the file the name backup dot tar dot gz so pretty much
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

246
10:55.280 --> 11:01.680
and then i'll just give the file the name backup dot tar dot gz so pretty much

247
11:01.680 --> 11:02.160
we're going to be

248
11:02.160 --> 11:06.020
creating a new file with the new hour minutes and seconds every time they

249
11:06.020 --> 11:07.280
happen to be ran so what

250
11:07.280 --> 11:09.970
i want to do first is i want to ensure that the directory happened to be

251
11:09.970 --> 11:10.960
created so i'll do an

252
11:10.960 --> 11:14.830
mkdir dash p which will allow me to create nested directories and all i will do

253
11:14.830 --> 11:15.680
is i specify that i

254
11:15.680 --> 11:19.920
want the backup directory to be created now if it already exists then we don't

255
11:19.920 --> 11:20.800
have to worry and

256
11:20.800 --> 11:25.870
then what i'm going to do is say tar dash czf and now i'm going to specify my

257
11:25.870 --> 11:26.960
path so i'll have my

258
11:26.960 --> 11:31.120
dollar sign for my interpolation i will say backup which will be this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

258
11:26.960 --> 11:31.120
dollar sign for my interpolation i will say backup which will be this

259
11:31.120 --> 11:32.960
particular directory and then

260
11:32.960 --> 11:37.450
i want to have a forward slash and then specify the actual file that is going

261
11:37.450 --> 11:38.480
to be inside of that

262
11:38.480 --> 11:41.940
directory which in this case here is going to be file underscore name again

263
11:41.940 --> 11:42.960
with that dollar sign

264
11:42.960 --> 11:47.280
for the interpolation now that is only going to specify the actual backup

265
11:47.280 --> 11:48.480
directory now we want

266
11:48.480 --> 11:52.000
to specify what it is that we want to copy over but we want to copy over

267
11:52.000 --> 11:53.280
everything within the

268
11:53.280 --> 11:57.250
important stuff directory so we can do that by opening our quotation marks once

269
11:57.250 --> 11:58.000
again and saying

270
11:58.000 --> 12:02.270
dollar sign source so if that's now done what we want to be able to do is you
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

270
11:58.000 --> 12:02.270
dollar sign source so if that's now done what we want to be able to do is you

271
12:02.270 --> 12:03.520
want to copy this

272
12:03.520 --> 12:08.190
particular file over onto both machines so the first thing i want to do is to

273
12:08.190 --> 12:09.440
copy over those files

274
12:09.440 --> 12:13.680
so if i happen to open up play one that one is allowing me to copy files over

275
12:13.680 --> 12:14.320
so i'll just copy

276
12:14.320 --> 12:19.040
that over here copy play one i'll copy this into play number three so let's go

277
12:19.040 --> 12:20.240
and edit this and

278
12:20.240 --> 12:25.230
i'm going to change the source here to backup dot SH that is that file and i'll

279
12:25.230 --> 12:25.680
change the

280
12:25.680 --> 12:31.080
destination of the file to be backup dot SH once again we're going to give it
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

280
12:25.680 --> 12:31.080
destination of the file to be backup dot SH once again we're going to give it

281
12:31.080 --> 12:32.560
executable permissions

282
12:32.560 --> 12:36.410
so if i just save this right here and i run the playbook and to enter now we

283
12:36.410 --> 12:37.280
should have copied

284
12:37.280 --> 12:41.290
that particular script over to both devices so if i cd into the temp directory

285
12:41.290 --> 12:42.800
to an ls we now have

286
12:42.800 --> 12:47.390
the backup SH script available on the yellow box and sliding over to the blue

287
12:47.390 --> 12:48.560
box once again we

288
12:48.560 --> 12:52.820
also have it available also on this box here so now the file happens to be

289
12:52.820 --> 12:53.840
present on both

290
12:53.840 --> 12:58.460
devices we want to schedule its execution regularly utilizing cron via answer

291
12:58.460 --> 12:59.440
able so let's create a

292
12:59.440 --> 13:03.190
new playbook called play four dot yml going to insert mode have a three hyphens
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

292
12:59.440 --> 13:03.190
new playbook called play four dot yml going to insert mode have a three hyphens

293
13:03.190 --> 13:04.160
or just say play

294
13:04.160 --> 13:09.360
four and i'll just say testing cron to backup file the host is going to be all

295
13:09.360 --> 13:10.240
gather facts is once

296
13:10.240 --> 13:14.170
again false and now we define the tasks so let's give this task a name i'll

297
13:14.170 --> 13:15.280
just do backup important

298
13:15.280 --> 13:19.150
stuff every minute like i say this is not a realistic example but it will allow

299
13:19.150 --> 13:19.920
us to execute

300
13:19.920 --> 13:23.900
quickly and now the module i'm going to use is going to be the answerable bel

301
13:23.900 --> 13:25.280
ton cron module

302
13:25.280 --> 13:29.680
and now we specify our information so we have to specify the name here that is

303
13:29.680 --> 13:30.640
actually required
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

303
13:29.680 --> 13:30.640
actually required

304
13:30.640 --> 13:36.670
let's just say backup every minute now i'm going to specify particular values

305
13:36.670 --> 13:37.360
now just remember

306
13:37.360 --> 13:40.840
if i wanted to run this every hour for example i could do this in a very

307
13:40.840 --> 13:42.080
readable way by using

308
13:42.080 --> 13:46.100
the special time option and in that case here i could just provide the value

309
13:46.100 --> 13:47.280
regularly okay

310
13:47.280 --> 13:51.990
however because minutely it's not actually a valid value for that particular

311
13:51.990 --> 13:52.800
parameter i'm

312
13:52.800 --> 13:57.120
going to have to do things the traditional way so all i will do here is specify

313
13:57.120 --> 13:58.160
the value minutes

314
13:58.160 --> 14:02.400
or rather the parameter minutes and i'll just give the value asterisk which it
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

314
13:58.160 --> 14:02.400
or rather the parameter minutes and i'll just give the value asterisk which it

315
14:02.400 --> 14:02.960
actually should be the

316
14:02.960 --> 14:07.250
default value but i'm just being explicit similarly i'm going to specify the

317
14:07.250 --> 14:08.320
hour and again it will

318
14:08.320 --> 14:12.240
be explicit with the asterisk now just to be clear here perhaps i didn't want

319
14:12.240 --> 14:13.280
to run every single

320
14:13.280 --> 14:17.170
minute maybe i wanted to run it every 30 minutes the way we do that which

321
14:17.170 --> 14:18.240
simply be to change the

322
14:18.240 --> 14:23.070
value here to 30 and that is going to be running every 30 minutes on the hour

323
14:23.070 --> 14:24.640
okay see how that works

324
14:24.640 --> 14:27.650
so now what i will do is provide the user that's going to run under which is

325
14:27.650 --> 14:28.320
going to be the

326
14:28.320 --> 14:31.220
answerable user and now i'm going to specify the job that i want to run but it
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

326
14:28.320 --> 14:31.220
answerable user and now i'm going to specify the job that i want to run but it

327
14:31.220 --> 14:32.080
's going to be a

328
14:32.080 --> 14:35.970
script and where is that script located well it's in the temp directory and it

329
14:35.970 --> 14:37.920
is called backup.sh

330
14:37.920 --> 14:41.940
so let's just provide that information so forward slash temp forward slash

331
14:41.940 --> 14:43.840
backup.sh and that

332
14:43.840 --> 14:48.310
should schedule the execution of this backup script every single minute and

333
14:48.310 --> 14:49.680
create those archives so

334
14:49.680 --> 14:53.610
let's just save this so with that now saved let's run the playbook and to enter

335
14:53.610 --> 14:54.800
give it a moment

336
14:54.800 --> 14:58.920
and now we can see we have scheduled the actual task itself so let's go over

337
14:58.920 --> 14:59.760
here so again if we

338
14:59.760 --> 15:04.200
go to the home directory so if i could do an LS notice we actually haven't got
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

338
14:59.760 --> 15:04.200
go to the home directory so if i could do an LS notice we actually haven't got

339
15:04.200 --> 15:05.280
the backups quite

340
15:05.280 --> 15:09.710
just yet if i say date we should be scheduled for a run in six seconds so i now

341
15:09.710 --> 15:10.720
say date again

342
15:10.720 --> 15:14.450
with no run do an LS look at this right here we have this backup directory now

343
15:14.450 --> 15:15.600
created if i go in

344
15:15.600 --> 15:21.270
here doing LS look at this we actually have the time five minutes past five in

345
15:21.270 --> 15:22.720
one second and then

346
15:22.720 --> 15:26.540
the backup tar file the same thing will be true over on the blue box so let's

347
15:26.540 --> 15:27.920
go to the blue box

348
15:27.920 --> 15:31.830
go to the answerable home directory doing LS we have the backup file doing LS
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

348
15:27.920 --> 15:31.830
go to the answerable home directory doing LS we have the backup file doing LS

349
15:31.830 --> 15:32.320
again we have

350
15:32.320 --> 15:36.330
that same backup now if i just say date here and around about 20 seconds we

351
15:36.330 --> 15:37.760
should have another run

352
15:37.760 --> 15:41.610
of backups that should appear within this directory so give it three more

353
15:41.610 --> 15:42.960
seconds now a new run should

354
15:42.960 --> 15:47.940
happen to an LS check this out right here now we have a second backup six

355
15:47.940 --> 15:49.840
minutes past the hour and

356
15:49.840 --> 15:54.000
again it should be comprised of everything within our important stuff directory

357
15:54.000 --> 15:55.120
such a trying on zip

358
15:55.120 --> 15:59.680
one for a moment just for testing so say tar exz vf let's need to go with a

359
15:59.680 --> 16:01.280
more recent one or six
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

359
15:59.680 --> 16:01.280
more recent one or six

360
16:01.280 --> 16:05.530
and to enter check this out right here look at the content we have backups of

361
16:05.530 --> 16:06.960
all of the information

362
16:06.960 --> 16:09.920
that we sought to keep
