This tutorial briefly covers the crontab, which is what you use to run scheduled tasks automatically. The crontab works by letting you set the minute, hour, day, week, and month of the task that you wish to run.
This means you can do a couple major things. Either you can set something to run once at a very specific time repeatedly, or you can have something run every "x" amount of time.
An example might be that you run an operation once a night at midnight. Another example might be that you run something every 5 minutes.
The cron tab is defined by 5 major time settings: minutes, hours, days, weeks, and months
An example from the PythonProgramming.net crontab is:
1 * * * * sudo echo 1 > /proc/sys/vm/drop_caches
The above code means the command of "sudo echo 1 > /proc/sys/vm/drop_caches" is run every time it is the "first minute." So every hour, at the 1 minute mark after the hour, that command is run.
Another example is:
0 */12 * * * sudo python /var/www/PythonProgramming/PythonProgramming/user-data-tracking.py
The above cron job runs every 12 hours. Another version of this cron is:
0 0,12 * * * sudo python /var/www/PythonProgramming/PythonProgramming/user-data-tracking.py
Both of these crons will run every 12 hours, but the first more appropriately describes it.
If you wanted to run something at 5 minutes, 12 minutes, and 49 minutes after the hour, you would use:
5,12,49 * * * *
An easy mistake to make, like I did in the video, is to forget about the minutes asterisk. The example I gave in the video was for "every 5 hours" being:
* */5 * * *
The above example actually means "every minute of every 5 hours." To fix this, you would want to do something like:
0 */5 * * *
Now this actually runs every 5 hours. Thanks to user mulchi01 on YouTube for correcting my mistake!