Copied to clipboard

crontab

`crontab` is a command used to schedule recurring commands on Unix and Linux systems. Users can simply store the commands they want to execute periodically in a crontab file, and the system will automatically execute these commands.

Example

  • Backup data every night at 11pm: 0 23 * * * /path/to/backup/script.sh
  • Clear log files every Monday: 0 0 * * 1 echo "" > /path/to/log/file.log
  • Run script every Saturday at 4pm: 0 16 * * 6 /path/to/script.sh
  • Run script every 30 minutes: /30 * * * * /path/to/script.sh
  • Run script on the first day of every month: 0 0 1 * * /path/to/script.sh

In the crontab file, each line represents a periodic task, and each column represents the execution time and command information of the task. You can use the crontab -e command to edit the crontab file, the crontab -l command to list the content of the current user's crontab file, and the crontab -r command to delete the current user's crontab file.