CRONTAB
CRONTAB:
Cron is named after the Greek word "Chronos" which is used for time. Crontab is a UNIX tool that generates a table or set of commands that will be run by the operating system at a specified time. On Linux systems, the crontab is used to automate various tasks.
Cron allows Linux and Unix users to schedule the execution of
commands or scripts at a particular time and date. Scripts can be designed to run
regularly. It is usually used
for system admin jobs such as backups or cleaning/tmp/ directories.
THE FOLLOWING POINTS SHOULD BE REMEMBERED WHILE WORKING WITH
CRON:
- Have a source version control to track and maintain the changes to the cron expressions.
- Organize the planned jobs by significance or frequency, and categorizes them by action or period.
- To begin, run the scheduled job with a high frequency.
- Do not explicitly write sophisticated code or many pipings and redirections in the cron expression. Instead, put them in a script and run it crontab.
- When the same set of instructions is regularly repeated, use aliases.
- Avoid running cron to run commands or scripts as the root user.
To start up a cron job on Ubuntu, follow these steps:
INSTALL CRON
#apt-get install cron use this command for installing CRON.
To check whether the CRON service is running on the system,
we can use the following command:
#systemctl status cron
CRONTAB COMMANDS:
Crontab -l: List the jobs for the current user
Crontab -e: Edit the job for the current user
After editing the job click ctrl+X, and next click on
Y to save the edited job.
Crontab -r: Remove all jobs for the current user.
If we want to delete cron enter crontab -r.
All jobs were removed successfully.
LINUX CRONTAB FORMAT:
MIN HOUR DOM MON DOW CMD
- * * * * * min, hr, day, month, day of week
- First * = minute (0 -59)
- Second * = hour (0-23)
- The third * = day of the month (1-31)
- Fourth * = Month (1-12) OR Jan to Dec
- The fifth* = Day of week (0-6) (Sunday = 0 or 7)
Every minute we get CPU, MEMORY, and DISK
monitoring data.
All data is stored in the Sep2.txt file.
CONCLUSION:
The crontab is a list of commands to execute regularly and
the name of the power used to administer that list. Crontab is an
abbreviation for "cron table," since it employs the job scheduler
cron to conduct tasks; cron is called after the Greek word "Chronos."
Comments
Post a Comment