1 Mission planning
To put it bluntly is a timer that runs a command or script that allows us to automatically perform any related tasks at rest time.
Look at its configuration file: Cat/etc/crontab
The first line defines the shell environment
The second line defines the environment variables
The third line defines the e-mail to the root user, the message save path is/var/spool/mail/root/
Finally, the format of the task content is defined, from left to right in the following sequence:
Time-sharing Weekly command
Minutes: 0-59
Hours: 0-23
Date: 1-31
Month: 1-12
Weeks: 0-7 0,7 all say Sunday
You can specify a range: for example, 1-5 weeks to Friday, can also be specified separately: For example 1, 2 can represent 1th and 2nd per month
* represents all times, */2 can represent even time periods
CRONTAB-E Create a task, this is equivalent to VI open a text, inside the operation is consistent with VI
-L View Tasks
-R Delete Task
-U followed by the user name, specifying which user's scheduled task, not specifying the default root user
After the task is created, be sure to ensure that the Task Scheduler service starts.
systemctl start crond.service
Start the Task Scheduler service
ps aux |grep crond
Check to see if there is a/usr/sbin/crond-n this process
Or systemctl status crond
view, the active (running) that appears in the green Word display indicates the start
The task is placed under/var/spool/cron/username, username refers to the corresponding user
Note: Whether you are scheduling tasks, iptables rules, or other shell scripts to use absolute paths as much as possible, scheduling tasks is best to feed the results of the command execution to the log,>> 2>> so that later
2 Chkconfig
Linux system service Management, similar to windos boot management. To familiarize yourself with the following basic usage:
chkconfig --list //查看所有服务chkconfig --level 345 network off //345级别的network服务关闭chkconfig --del network //删除network服务chkconfig --add network //添加network服务
Before you add a service, you need to put the service script in the/etc/init.d/folder
3 SYSTEMD Management
The system service management mechanism that CentOS 7 started using
Systemctl list-units--all--type=service//View all service services
A few common service-related commands
systemctl enable crond.service //让服务开机启动 systemctl disable crond //不让开机启动 systemctl status crond //查看状态 systemctl stop crond //停止服务 systemctl start crond //启动服务 systemctl restart crond //重启服务 systemctl is-enabled crond //检查服务是否开机启动
4 Unit and target
Unit is a component of a daemon, with multiple units forming a target
Ls/usr/lib/systemd/system//System all unit, divided into the following types
Service System Services
Target multiple units consisting of groups
Device hardware devices
Mount File System mount point
AutoMount Automatic mount point
Path file or path
Scope is not an external process initiated by SYSTEMD
Slice Process Group
Snapshot Systemd Snapshot
Socket inter-process communication sockets
Swap swap files
Timer Timer
Unit-related commands
systemctl list-units //列出正在运行的unit systemctl list-units --all //列出所有,包括失败的或者inactive的 systemctl list-units --all --state=inactive //列出inactive的unit systemctl list-units --type=service//列出状态为active的service systemctl is-active crond.service //查看某个服务是否为active
System to manage unit with target for ease of management
systemctl list-unit-files --type=target systemctl list-dependencies multi-user.target //查看指定target下面有哪些unit systemctl get-default //查看系统默认的target systemctl set-default multi-user.target //设置系统默认的target
Unit target Service Three relationships:
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 to see the
Which target the service belongs to.
Linux Learning Summary (27) mission planning, system service Management