Linux Task Scheduler cron, chkconfig Tools, SYSTEMD Management Service, Unit introduction, and Targe

Source: Internet
Author: User

I. Linux Task Scheduler cron
The operation of the Cron Task Scheduler function is done through the crontab command.
Among the options that are commonly used are:
-U: Specify a user, the no-u option is the current user;
/etc/crontab a configuration file for a task plan

The first two lines are defined variables, the third line refers to who sent the message, and then the last line has five points corresponding to five bits, that is, the above five elements,
respectively, say:
1. Indicates minutes (0-59)
2. Indicates hours (0-23)
3. Presentation date (1-31)
4. Indicates the month (1-12 can be written in digits or abbreviated in English)
5. means the week (0-6,0 or 7 means Sunday, also can be written in English shorthand)
The end of the last line is the user (the root user does not write the default is root)
The next section, where COM begins, is the command you want to execute.
Crontab-e Defining task Schedules (usage and VIM)

Left-to-right: 10:01 execute command on December 5 (This day must be Week 2) echo "OK" >/root/cron.log

Write format: Time-sharing Week user command
-L: Lists scheduled tasks;

-R: Delete Scheduled Tasks

Note:
Crontab-e actually opens the "/var/spool/cron/username" (if Root is/var/spool/cron/root) This file, so do not directly edit that file, because there may be errors, so be sure to use Crontab-e to edit, in addition to backup, directly copy the files in this directory can be

Make plan recommendations use the APPEND command >>, and append the correct and incorrect entries to a file.

Second, Chkconfig Tools (System service Management)
In fact, this is the system of all the default services, such as Network,cron and so on service (service name Start|stop|restart)

1. chkconfig–list See what the service side of this tool is using Chkconfig

Note: 0: Shutdown status
1: Single User
2: Multi-user mode with no NFS support
3: Full multi-user mode
4: Reserved for user customization
5: Graphical Login mode
6: Restart
ls/etc/init.d///server startup scripts are placed in this directory, only the startup script is placed in this directory in order to join the system services.
Turn on/Off the network Level 3:
Chkconfig--level 3 Network off/on
(Do not add –level 3 is to turn off all 0-6 levels)

To delete the network service side:
Chkconfig–del Network

Add the Network Service side (this command is required to add the service to the system service after you have added the startup script in the/etc/init.d/directory):
Chkconfig–add Network
Third, SYSTEMD Management services

To view all system services:
Systemctl List-unit-files

Lists the service conditions for all services (if none is added, the inactive state is not listed):
Systemctl List-units–all–type=service

A few common service-related commands
Enable a service to boot (. Service can be omitted):
Systemctl Enable Crond.service

Do not let boot start:
Systemctl Disable Crond

View Status:
Systemctl Status Crond

Stop service:
Systemctl Stop Crond

Start the service:
Systemctl Start Crond

Restart Service:
Systemctl Restart Crond

Check that the service is booting up:
Systemctl is-enabled Crond

Unit Introduction

System all unit, divided into the following types:
Ls/usr/lib/systemd/system
Service: System Services
Target: A group of more than one unit
Device: Hardware Device
Mount: File system mount point
AutoMount: Automatic mount point
Path: File or Path
Scope: External process not initiated by SYSTEMD
Slice: Process Group
Snapshot:systemd Snapshot
Socket: interprocess communication socket
Swap:swap file
Timer: Timer
Each of these types of files is a unit, and these units are formally composed of the various resources of the system (individual services, individual devices, etc.).
Unit-related commands

List the unit that is running (active):
Systemctl list-units

List all, including failed or inactive:
Systemctl List-units–all

List the unit for inactive:
Systemctl list-units–all–state=inactive

List the service for all States:
Systemctl List-units–all–type=service

List the service with Active status:
Systemctl List-units–type=service

To see if a service is active:
Systemctl is-active Crond.service
Iv. unit-related commands:

System all unit, divided into the following types:
Ls/usr/lib/systemd/system
Service: System Services
Target: A group of more than one unit
Device: Hardware Device
Mount: File system mount point
AutoMount: Automatic mount point
Path: File or Path
Scope: External process not initiated by SYSTEMD
Slice: Process Group
Snapshot:systemd Snapshot
Socket: interprocess communication socket
Swap:swap file
Timer: Timer
Each of these types of files is a unit, and these units are formally composed of the various resources of the system (individual services, individual devices, etc.).

List the unit that is running (active):
Systemctl list-units

List all, including failed or inactive:
Systemctl List-units–all

List the unit for inactive:
Systemctl list-units–all–state=inactive

List the service for all States:
Systemctl List-units–all–type=service

List the service with Active status:
Systemctl List-units–type=service

To see if a service is active:
Systemctl is-active crond.service**

Five, Target introduction

System to manage unit with target for ease of management

List all the target of the system:
Systemctl List-unit-files–type=target

See which unit is below the specified target, such as the following multi-user:
Systemctl list-dependencies Multi-user.target


To view the system default target:
Systemctl Get-default


Set the default target:
Systemctl Set-default Multi-user.target

A service belongs to one type of unit

Multiple unit consists of a target

A target contains multiple service

Cat/usr/lib/systemd/system/sshd.service//See [Install] section, define which target the service belongs to

Linux Task Scheduler cron, chkconfig Tools, SYSTEMD Management Service, Unit introduction, and Targe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.