|
194 | 194 | *** day of month (1-31)
|
195 | 195 | **** month (1-12)
|
196 | 196 | ***** day of week (1-7)
|
| 197 | + |
197 | 198 | """
|
198 | 199 |
|
199 | 200 | """
|
|
202 | 203 | -Which of the following is the correct Crontab syntax for execute the Python model script (model.py) every hour, on the 15 minute of an hour?
|
203 | 204 | (e.g. 12:15 PM, 1:15 AM, 2:15 AM, etc)?
|
204 | 205 |
|
205 |
| -Answer : 15 * * * * python model.py |
206 |
| -""" |
| 206 | +Answer : 15 * * * * python model. |
207 | 207 |
|
| 208 | +""" |
208 | 209 |
|
209 | 210 | """
|
210 | 211 | ### Scheduling a job with crontab
|
211 | 212 |
|
212 | 213 | -Verify that there are currently no CRON jobs currently scheduled via CRONTAB.
|
| 214 | +
|
213 | 215 | """
|
214 | 216 | # Verify that there are no CRON jobs currently scheduled
|
215 | 217 | crontab -l
|
|
225 | 227 |
|
226 | 228 | # Verify that the CRON job has been added
|
227 | 229 | crontab -l
|
| 230 | + |
| 231 | + |
| 232 | +""" |
| 233 | +### Model production on the command line |
| 234 | +
|
| 235 | +In this capstone exercise, we will practice how to set up an end-to-end Python script automation process step by step. |
| 236 | +
|
| 237 | +Instructions |
| 238 | +100 XP |
| 239 | +Use pip to install the Python dependencies listed in the requirements.txt file. |
| 240 | +
|
| 241 | +-Now that the necessary Python dependencies have been installed, run the create_model.py script on the command line. |
| 242 | +-We have verified that the Python model can be run. Next step is to automate this job so it runs every minute. Use CRONTAB to schedule a per minute run of the Python |
| 243 | + script create_model.py. |
| 244 | +-Print the job scheduled in CRONTAB to verify that the CRON job is scheduled correctly. |
| 245 | +
|
| 246 | +""" |
| 247 | +# Preview both Python script and requirements text file |
| 248 | +cat create_model.py |
| 249 | +cat requirements.txt |
| 250 | + |
| 251 | +# Pip install Python dependencies in requirements file |
| 252 | +pip install -r requirements.txt |
| 253 | + |
| 254 | +# Run Python script on command line |
| 255 | +python create_model.py |
| 256 | + |
| 257 | +# Add CRON job that runs create_model.py every minute |
| 258 | +echo "* * * * * python create_model.py" | crontab |
| 259 | + |
| 260 | +# Verify that the CRON job has been scheduled via CRONTAB |
| 261 | +crontab -l |
0 commit comments