How to use Linux to calculate the disk space occupied by timed files

How to use Linux to calculate the disk space occupied by timed files

Open the scheduled task editor. Cent uses vim to open it directly by default. If ubutun is installed with multiple editors, the first time you open it, you will be prompted to specify the editor.

insert image description here

(3) */1 * * * * sh /root/Shell/monitor.sh Add this line to the file. It means to execute the sh /root/Shell/monitor.sh command every one minute. For more specific timing formats, please check online. This is all you need for simple loop monitoring

insert image description here

(4) service crond start starts the scheduled task. On ubutun it is service cron start

insert image description here

(5) Check whether the crontab scheduled task has been started crontab -l

insert image description here

2. Shell monitoring disk

(1) du -BM /root/Shell/a.pdf | awk '{print $1}' to get the file size. The -BM output is M, if G output is required, use -BG.

(2) cachesize=$( du -BM /root/Shell/a.pdf | awk '{print $1}') uses the cachesize variable to receive the file size. Note that the received data is with units, such as 89M.

(3) cachesize=$(echo ${cachesize/M/}) Remove M to get a pure number 3. Complete code

If the size of the file a.pdf is greater than or equal to 90M

Summarize

The above is the operation method of Linux to implement the size of disk space occupied by timed files introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Autotrash tool for Linux to automatically delete old junk files at a scheduled time
  • Use Linux shell script to implement FTP scheduled execution of batch download of specified files
  • Script for regularly deleting files older than a certain day in Windows and Linux
  • Linux VPS backup tutorial database/website file automatic scheduled backup
  • How to expand the root directory disk space in Linux system
  • Detailed explanation of Linux disk formatting commands
  • Detailed explanation of Linux virtual machine root partition disk expansion space record
  • Linux view disk space size command
  • How to use du to view the size of disk space occupied by a file or directory in Linux
  • How to view Raid disk array information in Linux
  • How to expand the disk capacity of a Linux server (picture)
  • How to use GPT partitioning on Linux disks larger than 2T

<<:  Use of JavaScript sleep function

>>:  Detailed explanation of the problem of mixed use of limit and sum functions in MySQL

Recommend

UDP connection object principle analysis and usage examples

I wrote a simple UDP server and client example be...

JavaScript modularity explained

Table of contents Preface: 1. Concept 2. The bene...

Installation process of zabbix-agent on Kylin V10

1. Download the installation package Download add...

How to get/calculate the offset of a page element using JavaScript

question By clicking a control, a floating layer ...

Common methods of Vue componentization: component value transfer and communication

Related knowledge points Passing values ​​from pa...

Install and configure MySQL 5.7 under CentOS 7

This article tests the environment: CentOS 7 64-b...

How to use MySQL group by and order by together

Suppose there is a table: reward (reward table), ...

How to configure multiple projects with the same domain name in Nginx

There are two ways to configure multiple projects...

What to do if you forget your password in MySQL 5.7.17

1. Add skip-grant-tables to the my.ini file and r...

How to display JSON data in HTML

background: Sometimes we need to display json dat...

MySQL configuration SSL master-slave replication

MySQL5.6 How to create SSL files Official documen...

Install and configure ssh in CentOS7

1. Install openssh-server yum install -y openssl ...