Sometimes you'll have a script that you want to run at preset intervals. For example, maybe you want to clean up all the old screenshots on your desktop once a week. You can use cron jobs to automate these repetitive tasks.
crontab -l
: List the cron jobs for the current usercrontab -e
: Edit the list of cron jobs for the current user
* * * * * command to execute
Each *
represents a value, listed in order here:
- Minute (
0
-59
) - Hour (
0
-23
) - Day of month (
1
-31
) - Month (
1
-12
) - Day of week (
0
-6
(where0
is Sunday), orSUN
-SAT
)
* * * * * ./runScript.sh
*/5 * * * * ./runScript.sh
30 10 * * 0 ./runScript.sh