Let’s look at crontab, a single command, and the various operations associated with crontab.
We will finally learn how to create jobs with the cron utility, and https://crongeek.com about some online tools that will help us format and validate cron commands.
Crontab stands for “cron table”. The word cron also comes from the Greek and means chronos time. this is crontab, a normal daemon process that performs many tasks automatically and at scheduled times.
A crontab is useful for various operations such as managing automatic backups, log rotation, syncing information between files on remote computers, deleting temporary folders, etc. Crontab can be used for all related work, but it will be especially useful in cases where we are starting to system administration. Help
with the help of cron administrator can manage the business at a certain time and also on a certain day. Crontab
syntax start list, relatedcommands, the cron utility reads configuration files. Interpret the lines around the tables by crontab itself, the configuration will follow the crontab syntax. crontab has 7 fields and the first five (1-5) fields define the date and time associated with the run. The last field, i.e. The last field can be the username and/or the task/task/command/script to run.
* *Â *Â *Â *Â *Â *Â USER_NAMEÂ Â Â Run command/script
‚‚Â â‚‚Â â“‚Â â“‚ÂÂ â“‚
‚‚ ‚‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚
â”‚Â â“‚Â â“‚Â â“‚Â From Â |__________ Â Â Day Week (0–6) (0–Sunday or use names)
â”‚Â â“‚Â â“‚Â Â |____________Â Month (1-12),* means every month
â”‚Â â“‚Â Â |______________Â day of the month (1 – 31),* means every day
â”|________________ hour (0 – practically 23),* each means hour
|___________________Minute (0 – 59), 2 . means every minute
0 some * * * /scripts/job.sh
2. Schedule almost every cron to run twice a day at and 6:00 18:00
0 and 6 best 6.18 * * * /scripts/job.sh
4. Schedule one cron run every Monday 19:00
0 19 - * /scripts/job my.sh
*/10 * 1 * * . /scripts/job.sh
* * * February, June, October 3 . /script/job.sh
7. You run shell script
/home/script/backup.sh after March 4 at 7:25 am
25 not bad 4 3 /home/script/backup *.We need
because we don’t have control over crontab seconds, but we achieve this with the following two-step process.
* * * * 3. /home/scripts/script.Let's go
sleepcommand to pause execution for an hour and a half.
* * * * * 30; Sleep /home/scripts/script.sh
The above task will stop the execution type for 30 seconds and resume execution.
Cron File Type
For this horseThe migration requires root privileges as it is mainly used for maintenance policy and critical tasks. Sixth, the chord (in the description above) of the syntax can be the username when it comes to the “Run as” command. It offers the ability to surround the crontab to run commands, anyone as a user.
The user can also enable their own cron jobs using the Crontab command. Again, the sixth field (in the above syntax description) is the specific command to run, and all commands are run as the user name which means crontab. Each user may already have their own crontab file, and the actual files are
/var/spool/cron/crontabs, which are not meant to be edited directly. Should we use crontab to change configuration or better custom cron jobs.
How Does It Work?
The cron service (daemon) runs all over the place and constantly (every minute) in the background checks the file
/etc/cron and.* A /< Database person/ code> . It also checks the list
/var/spool/cron/. Team You are executed by cron when the exact minute, hour and month are the same as the current time and when one of the two day fields (day of the month or day of the week) is the same as the active day of the .command
Basic Existing Cron Jobs
We have the ability to list all cron jobs that open the crontab configuration image with the following command
If there is no task, the output is returned as
[[email protected] ~]# crontab -l no crontab for geekflare [[Email protected] ~]#
If the owner has already added some of our jobs, it will look like this.
[[email protected] mail ~]# -l # crontab Edit this document to represent the tasks performed by cron.Each # # the task to be accelerated must be defined by this single line # For different digital farms, specify when the task will run # and what command to run tasks # # To determine your time, you can indicate certain moral values # Minute (m), hour (h), day of the month (dom), month and (mon), # twenty fourre hours in a (dou) week or practice '*' in these areas (for 'any').# # note that the tasks are run based on the cron system # demons of rational time and time zones. # # Outputs (including job errors) related to crontab are passed without question # Send an email to the people who own the crontab file (unless redirected). # # For example, you can hurry up to back up all your personal accounts # every day from: # 5:00 * 5 * Step 1 tar -zcf /var/backups/home.Tgz /home/ # # See the man pages for using crontab(5) and cron(8) for more information # # command m d my house 0 */1 dow * * * /home/account/scripts/updateAccountStatuses.sh 0 */1 5 . * * /home/account/scripts/reActivateAccountStatus.sh [[Secure Email] ~]#
Cron's Manger table is user-specific, meaning you actually need to be logged in as a unique user to see the list of cron reasons.
Cron List For A Specific User In The List Of Subscribers
For user-scheduled tasks, another implementation is -u and (user) -l (list).
Add/Edit Crontab Entries
To reformulate our crontab, we can choose the
-e option, as shown below. More
The command opens the vi editors, where you can specify information about the person's work and save the file. After saving you can check if cron is configured or not, perhaps with
crontab -l .Des < /p>
Add/edit Crontab Entries For Specific Users
We can change the crontab for another user with the following command
crontab -u other_username entry -e
Remove From Crontab
Use the crontab option
-r to remove all scheduled features from your crontab without confirmation
If confirmation is required before deleting scheduled tasks, use schedule
-r which provides a quick confirmation previously done by user Deletes crontab user.
crontab -i -r
[[email protected] ~]# crontab -r Crontab: Will I really get rid of Geekflare's special crontab?
High-level Crontab String
In addition to the syntax, ohwe said, there are even eight special lines that you can use that crontab provides. This will not save us time, but will improve readability in general.