Crontabs, a very useful and most important tool to use it for repetitive jobs. It has most customizable schedule options to execute a job at any number of times. Think of it like a calendar reminder for your computer. You can set it up to run a specific command, such as making a backup of your files, every day at a certain time or even every hour. This way, you don't have to manually run the command every time, and you can be sure that the task will be done automatically. >> crontab -l # Example of job defination: # .---------------- minute (0 - 59) # | .-------------- hour (0 - 23) # | | .------------ day of month (1 - 31) # | | | .---------- month (1 - 12) OR jan,feb,mar,apr # | | | | .-------- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue.wed,thu,fri.sat # | | | | | .------ command to execute # | | | | | | */1 * * * * date >> ~/date.log The first five fields represent the time and date when the command should be executed.
The asterisk (*) is a wildcard that matches any value. The user can schedule a command to run at a specific time of the day and specific day of the week by providing the appropriate values in the fields. To create a new cron job, you can use the crontab -e command to open the crontab file in a text editor, and then add a new line with the desired schedule and command. To view the current cron jobs, you can use the crontab -l command. To delete a cron job, you can use the crontab -r command. Users can also schedule a command to run at a specific time of the day and specific day of the week by providing the appropriate values in the fields. Cron has a system-wide configuration file located at /etc/crontab, which can be used to schedule system-wide tasks that run with root privilege. Cron jobs can be used to automate a wide variety of tasks, such as running backups, sending emails, updating databases, and more. They can be created and managed by individual users, but only the root user can schedule system-wide tasks that run with root privilege. By default, cron sends an email to the user account executing the cron job, if any output is produced by the command. If a cron job is not working as expected. To practice more on cronjob scheduler check crontab.guru website. A free website to show about the crontab schedule output in words. |