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

How to deploy a simple c/c++ program using docker

1. First, create a hello-world.cpp file The progr...

20 Signposts on the Road to Becoming an Excellent UI (User Interface) Designer

Introduction: Interface designer Joshua Porter pub...

HTML is the central foundation for the development of WEB standards

HTML-centric front-end development is almost what ...

Mysql join table and id auto-increment example analysis

How to write join If you use left join, is the ta...

Css3 realizes seamless scrolling and anti-shake

question The seamless scrolling of pictures and t...

CentOS7 uses rpm to install MySQL 5.7 tutorial diagram

1. Download 4 rpm packages mysql-community-client...

How to solve mysql error 10061

This article shares with you the solution to the ...

About Vue virtual dom problem

Table of contents 1. What is virtual dom? 2. Why ...

Docker deploys Laravel application to realize queue & task scheduling

In the previous article, we wrote about how to de...

Solutions to Files/Folders That Cannot Be Deleted in Linux

Preface Recently our server was attacked by hacke...

vue-table implements adding and deleting

This article example shares the specific code for...

Detailed explanation of how two Node.js processes communicate

Table of contents Preface Communication between t...

Introduction to common commands and shortcut keys in Linux

Table of contents 1 System Introduction 2 System ...