当前位置:网站首页>[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 .
边栏推荐
- Wechat applet simply realizes chat room function
- Which of the top ten securities companies has the lowest Commission and is the most safe and reliable? Do you know anything
- JSON. toJSONString(object, SerializerFeature.WriteMapNullValue); Second parameter action
- Three laws of go reflection
- Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
- Flask 的入门级使用
- DNS domain name system
- ASP. Net core - Safety of asynclocal in asp NET Core
- Acwing2013. three lines
- レレ / 蕾蕾
猜你喜欢

Understand what ICMP Protocol is

Sleep quality today 67 points

The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse

sin(a-b)=sina*cosb-sinb*cosa的推导过程

Who can teach me how to learn SCM, what to learn first and how to get started?

Navicat防止新建查询误删

直接选择排序和快速排序

【2022黑马程序员】SQL优化

Wechat applet authorization login + mobile phone sending verification code +jwt verification interface (laravel8+php)

DataX tutorial (09) - how does dataX achieve speed limit?
随机推荐
What does cardinality mean in set
What is cloud primordial?
How to record a database [closed] - how to document a database [closed]
Wan Yin revealed that he was rejected by MIT in this way: "the department doesn't like you". He confronted the principal and realized
Bcrypt password encryption kalrry
Tp6 interface returns three elements
Brief introduction and use of JSON
Coffee script unmatched outent error
Arm register (cortex-a), coprocessor and pipeline
[v2.0] automatic update system based on motion step API (support disconnection reconnection and data compensation)
Ht81293 built in adaptive dynamic boost 20W mono class D power amplifier IC solution
Navicat防止新建查询误删
Report on development status and investment strategy recommendations of global and Chinese graphite polystyrene board industry 2022-2028
SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-
Zero foundation wants to learn web security, how to get started?
How to realize hierarchical management of application and hardware in embedded projects
Wechat applet simply realizes chat room function
ACWING2013. 三条线
From file system to distributed file system
3dmax软件的制作木桶过程:三步流程