当前位置:网站首页>[learn shell programming easily]-5. Plan tasks
[learn shell programming easily]-5. Plan tasks
2022-06-25 06:41:00 【FanMY_ seventy-one】
1、 Planning tasks
Create and manage tasks that are automatically executed at a specified time
matters needing attention : To make a task schedule run automatically at a specified time , The service that schedules the task must be started .
1.1、 Classification of planned tasks
- Use at Command invocation atd process Set at a specific time , Perform a task
- Use crontab Command invocation crond process , Set according to a fixed period ( Like every day , Wait a week ) Repeat pre planned tasks
crond Progress is always running
[[email protected] ~]# ps aux|grep crond
root 693 0.0 0.0 126384 1624 ? Ss 13:16 0:00 /usr/sbin/crond -n
1.2、 Daemon (Daemon)
Definition : Processes that have been running in memory , Until we stop it artificially , Otherwise, it is always running in memory . Because it's always running in memory , So our users can visit at any time .
If we use "ps aux" Order to see , You will see a lot of bands at the end "d" The process of , So these processes are daemons .
1.2.1、 The five states of a process

The above guard status , Yes, always " function "、" Blocking "、" be ready " These three states are cyclic .
1.3、at command
Definition : On a specified date 、 Some preset command operations are automatically executed at the time point , This is a one-time scheduled task
- The name of the system service :/etc/init.d/atd
- Format :at [HH:MM] [yyyy-mm-dd]

When setting tasks , First of all, we have to start std process , Otherwise, they will not perform scheduled tasks regularly .
[[email protected] rough_book]# service atd start
Redirecting to /bin/systemctl start atd.service
[[email protected] rough_book]# ls
[[email protected] rough_book]# at 21:58
at> mkdir fan$RANDOM
at> <EOT> # Use ctrl+d, Submit scheduled tasks
job 1 at Thu Jun 23 21:58:00 2022
# View the current scheduled task list
[[email protected] rough_book]# at -l
1 Thu Jun 23 21:58:00 2022 a root
# Wait to 21:58, You can see that there is a new file .
[[email protected] rough_book]# ls
fan28985
# Delete the scheduled task with No 2 The task of ,atrm Equivalent to at -d
[[email protected] rough_book]# atrm 2
1.3.1、 Plan where tasks are stored
Where the task is stored :/var/spool/at
[[email protected] rough_book]# at -l
4 Thu Jun 23 22:03:00 2022 a root
[[email protected] rough_book]# ls /var/spool/at
a0000401a5240b spool
# The principle is atd It's time for this process , They will execute /var/spool/at In the corresponding a Opening file .. because linux All the documents inside . Once the task is completed , The files will disappear .1.3.2、batch
batch Is and at It's about the same plan Make .batch It will automatically run when the system load is not high . So when not busy ? The average load is less than 0.8
[[email protected] rough_book]# top
top - 22:10:28 up 8:54, 5 users, load average: 0.00, 0.01, 0.05
# Check how long the system has been powered on , And the average load of the system
[[email protected] rough_book]# uptime
22:10:51 up 8:54, 5 users, load average: 0.00, 0.01, 0.05
# load average The following three numbers represent : stay 1、5、15 Average load in minutes
# Both commands can view the load of the system Average load : It's a period of time (1、5、15 minute ) The average number of runnable or non interruptible processes . It can be understood as ready team and operation 、 The number of processes in the block . The value is the same as CPU The nucleus of .
man uptime: see uptime The following information about the average load of the system can be found in the manual
System load averages is the average number of processes that are either in a runnable or uninter‐ ruptable state. A process in a runnable state is either using the CPU or waiting to use the CPU. A process in uninterruptable state is waiting for some I/O access, eg waiting for disk. The averages are taken over the three time intervals. Load averages are not normalized for the number of CPUs in a system, so a load average of 1 means a single CPU system is loaded all the time while on a 4 CPUsystem it means it was idle 75% of the time.
The average load of a system is the average number of processes that are in an operational or non interruptible state . A process in a runnable state is using CPU, Or waiting to be used CPU. The process in a non interruptible state is waiting for some I/O visit , Like waiting for disk . Take the average of the three time intervals . The average load is not based on CPU The number of , So the average load is 1 It means a single CPU The system is always loaded , and CPU The number of 4 individual CPU System , It means that the 75% My time is free .
2、crond process
crond Process is every 1 Check the user's scheduled tasks in minutes ;crond It is installed by default and will run automatically after startup . See the following blog for details .
边栏推荐
- Grouped uitableview has 20px of extra padding at the bottom
- Derivation of COS (a-b) =cosa*cosb+sina*sinb
- 2022 AI trend 8 forecast!
- How do I check swift if two arrays contain the same elements, regardless of the order in which they appear?
- [short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]
- Non-contact infrared temperature measurement system for human body based on single chip microcomputer
- PHP converts strings to hex and hex to string - PHP convert string to hex and hex to string
- Acwing / 2004. Mauvaise écriture
- Cve-2022-23131 - bypass SAML SSO authentication
- Three laws of go reflection
猜你喜欢

How to realize the stable output of 3.3v/3.6v (1.2-5v) voltage of lithium battery by using the voltage rise and fall chip cs5517

百度地图——入门教程

SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-

Are you still doing the dishes yourself? Teach you how to make dishwasher controller with single chip microcomputer

Personal blog system graduation project opening report

Wan Yin revealed that he was rejected by MIT in this way: "the department doesn't like you". He confronted the principal and realized

Power representation in go language

【2022黑马程序员】SQL优化

Cs8683 (120W mono class D power amplifier IC)

Derivation of sin (a-b) =sina*cosb-sinb*cosa
随机推荐
百度地图——入门教程
Three laws of go reflection
Wechat applet authorization login + mobile phone sending verification code +jwt verification interface (laravel8+php)
How do I turn off word wrap in iterm2- How to turn off word wrap in iTerm2?
Kubernetes core components etcd details
We cannot activate inspection type for article master in transaction code MM41?
[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]
聚类和分类的最基本区别。
Derivation of sin (a-b) =sina*cosb-sinb*cosa
TorchServe避坑指南
[200 opencv routines of youcans] 104 Motion blur degradation model
集群常用群起脚本
mysql 表查询json数据
原子Alpha开发板--SD卡和emmc烧录工具
VMware virtual machine prompt: the virtual device ide1:0 cannot be connected because there is no corresponding device on the host.
From file system to distributed file system
fastadmin 联级清空数据
Non-contact infrared temperature measurement system for human body based on single chip microcomputer
System dilemma and software complexity: Why are our systems so complex?
Bcrypt password encryption kalrry