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

How to use the Crontab configuration file under Linux

2025-03-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the knowledge of "how to use Crontab configuration files under Linux". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

[global (system) profile]

The code is as follows:

/ etc/crontab

The main configuration files for Linux are in the etc directory.

The code is as follows:

Cd / etc

Ls cron*

The code is as follows:

Vim crontab

Enter cron.d (Service)

The code is as follows:

Cd cron.d

Use the cat command to view the sysstat file (the cat command is a text output command under linux, usually used to view the contents of a file)

The code is as follows:

Cat sysstat

You will find that the content you view is very similar to that of crontab-l.

When crontab loads the configuration file, the configuration information in the file below cron.d will be loaded into the scheduled task of root users. If you use the crontab-e command to edit it, it will actually destroy the contents of its original file configuration, so you are generally reluctant to use crontab-e. If you edit the file directly: vim sysstat, and then use crontab-l at this time, you will find that the edited file will not be loaded directly (the content viewed by crontab-l will not change). You can load the file by crontab sysstat (crontab followed by a file), and then use crontab-l to view it. At this time, the contents of the file cover everything in the original crontab-l. So be very careful when importing with crontab followed by a file, because the contents of crontab-e will be copied by the file. To ensure that a scheduled task is not lost, it is usually not to use crontab-e, but to add it in a file and then load it, so that when the system restarts, these files are automatically loaded into the scheduled task list, note that this is loaded as a root user.

When using the ls cron* command, there will be an one-cron.d directory, which is the directory of the configuration files. The sysstat under it is very similar to the crontab file in the etc directory.

Contab cannot edit scheduled tasks in system-level configuration files (for example, create a new scheduled task file crontst under cron.d and write * / 1 * dee echo "File in / ect/cron.d/crontst****" in it, and then: wq! Save the exit, and you can use tail-f / var/log/cron to monitor the execution of the scheduled task, but you cannot list the scheduled task using crontab-l or crontab-e.)

[supplement]

Use first

The code is as follows:

Crontab-l

Reuse

The code is as follows:

Cat / var/spool/cron/root

You will find that the output of the two commands is the same:

In fact, when crontab operates, it operates on the file / var/spool/cron/root.

Can be used

The code is as follows:

Ls / var/spool/cron/root

View the scheduled tasks for all users.

[Root profile]

Only Root users will load these into the scheduled task list.

This is the end of the content of "how to use the Crontab configuration file under Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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