crontab
Crontab is a command line tool used in Unix-like operating systems (such as Linux) to manage the scheduling of periodic tasks. The name "crontab" is derived from "cron table," as it allows users to create, edit, list, and delete cron jobs.
Cron jobs are commands or scripts that are scheduled to run at specific times or intervals. These jobs are defined in crontab files, which are maintained by the crontab command. Each user has their own crontab file, and the associated jobs are executed under the user's account.
Using crontab, you can schedule tasks to run at minute, hour, day of the month, month, and day of the week levels of granularity. Crontab also allows you to specify commands to be executed, shell scripts to run, and more.
With crontab, you can:
-
Add a cron job: You can create a new cron job and define its schedule using the crontab command.
-
Edit an existing cron job: You can modify the schedule or command/script of an existing cron job.
-
List cron jobs: You can view a list of all the cron jobs defined in your crontab file.
-
Remove a cron job: You can delete a specific cron job from your crontab file.
Crontab is a powerful tool for automating repetitive tasks, such as backups, system maintenance, data synchronization, script execution, and more. It allows you to schedule jobs without the need for manual intervention, making it highly useful for system administrators and regular users alike.
List of commands for crontab:
-
crontab:edit Edit the crontab file for the current user.$ crontab -etry on your machineexplain this command
-
crontab:edit:user Edit the crontab file for a specific user.$ sudo crontab -e -u ${user}try on your machineexplain this command
-
crontab:remove Remove all cron jobs for the current user.$ crontab -rtry on your machineexplain this command
-
crontab:show Show a list of existing cron jobs for current user.$ crontab -ltry on your machineexplain this command
-
crontab:tldr:aa218 crontab: Replace the current crontab with the contents of the given file.$ crontab ${filename}try on your machineexplain this command