Raspberry Pi-Cron and Crontab (scheduled task)
Cron is a tool for configuring scheduled tasks in Unix systems. It is used to execute commands or scripts on a regular basis or at a certain interval; the task scope can be to automatically back up the user's home folder every night, or to record CPU information logs every hour.
The crontab (cron table) command is used to edit the list of scheduled tasks in execution. The operation is based on each user, and each user (including the root user) has its own crontab.
Editing crontab (edit crontab)
Run crontab and-e to edit the cron table:
Crontab-e
Select an ediror (select an editor)
The first time you run the crontab command, you will be prompted to select an editor. If you are not sure which one to use, you can press enter to select the default nano editor.
Each cron object contains six parts: minute, hour, day of the month, and day of the week, and scheduled command.
# M h dom mon dow command # ***** command to execute # Too many commands available # │ #│ │ # │ ── ─ the day of the week (0-7) (from 0 to 6 indicates Sunday to Saturday. 7 indicates Sunday, equivalent to 0) # │ └ ── ─ month (1-12) # │ └ ── ─ day in the month (1-31) # │ ── ─ hour (0-23) # └ ── ─ minute (0-59)
For example:
0 0 ***/home/pi/backup. sh
The cron instance will execute the backup. sh script at midnight every day. Address: http://www.raspberrypi.org/documentation/linux/usage/cron.md