📅  最后修改于: 2023-12-03 15:30:07.424000             🧑  作者: Mango
Crontab is a tool that runs on Unix/Linux systems and allows you to schedule tasks to run automatically at specific times and intervals. It is a time-based job scheduler in Unix-like operating systems that executes commands or scripts at specified dates and times.
To view your crontab entries, use the following command:
crontab -l
This will display your current crontab entries.
To edit your crontab entries, use the following command:
crontab -e
This will open your crontab file in the default text editor specified in the EDITOR
environment variable.
To add a new crontab entry, use the following command:
crontab -e
Enter the new crontab entry in the file. The format of a crontab entry is as follows:
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of the week (0 - 6) (Sunday is 0)
| | | +------- month (1 - 12)
| | +--------- day of the month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
To remove a crontab entry, use the following command:
crontab -r
This will remove all of your crontab entries.
Here are some examples of how to use crontab:
* * * * * /path/to/script.sh
0 * * * * /path/to/script.sh
0 0 * * * /path/to/script.sh
0 0 * * 1 /path/to/script.sh
Crontab is a powerful tool that allows you to schedule tasks to run automatically at specific times and intervals. With a little bit of practice, you can easily automate routine tasks such as backups, updates, and data processing.