Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Talking about the Command usage of crond and crontab under Linux

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What is crond?

Crond is a service or software that the Linux system uses to execute commands or specify programs on a regular basis. In general, when we have installed the Linux operating system, the Crond task invocation service will be started by default. The Crond service checks the system periodically (by default, once a minute) to see if there are any tasks to be performed. If so, the scheduled task work is automatically executed according to its preset scheduled task rules. This Crond timing service is just like our alarm clock.

Crontab is an instruction used to set up periodic execution, which reads instructions from standard input devices and stores them in a "crontab" file for later reading and execution.

II. The usage of crontab

1. Introduction to crontab grammar

Crontab is used to allow users to execute programs at fixed times or intervals, that is, similar to a user's schedule.

Permission to use

Root user and owner of the crontab file

Grammar

Crontab [- e [username]] | [- l [UserName]] | [- r [username]] | [- v [UserName] | File]

Parameter resolution:

-e: execute a text editor to set the timetable. The internal text editor is vi. If you need to use other text editors, you need to set the VISUAL environment variable to specify which text editor to use. -r: delete current calendar-l: list current schedule-v: list user cron job status

Format of the timetable:

How to use it:

Edit a file cornfile with VI, and then enter a well-formed schedule in the file. When the editing is complete, save and exit. Then enter at the command line in root mode:

Crontab cornfile

This submits the cornfile file to the cron process, and a copy of the newly created cronfile has been placed in the / var/spool/cron directory with the file name as the user name.

Test case:

/ bin/Is:0 * / bin/Is every day in December, every day from 6 a.m. to 12:00, every 20 minutes / usr/bin/backup:*/20 6-12 * 12 * / usr/bin/backup send a letter to alex_mail_name:0 17 * 1-5 mail-s "hi" alex_mail_name at 5:00 every Monday to Friday.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report