Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Scheduled tasks and delayed tasks under linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Detailed explanation of setting scheduled task and delayed task by using at command

1 > scheduled tasks:

Format:

[root@localhost ~] # at 23:37

Set task execution time

At > Task Action

At > (task initiated directly by ctrl+d will be displayed) initiate task with ctrl+D

2 > the at command is used for deferred tasks

Format:

[root@localhost ~] # at now+1min

At > perform actions

At > ctrl+d exit start delay task timing

3 > at View and stop commands

At-l lists scheduled tasks

At-c 2 View tasks with serial number 2

At-r 3 Delete the task with serial number 3

4 > at task blacklist and whitelist

/ etc/at.deny # # blacklist, which exists by default in the system. Users who appear in this file cannot execute at

/ etc/at.allow # # whitelist, which does not exist in the system by default. Ordinary users appearing in this file can execute at, only those on the list can, and / etc/at.deny is invalid.

Note: comparison of allow deny priorities

/ etc/at.allow exists / etc/at.deny becomes invalid

When student appears in both allow and deny, deny becomes invalid, so student can use the at command

two。 Using crontab command to set system timing task

1.crond.service # # the scheduled task takes effect when the program is opened

two。 Parameters:

E stands for editor

U represents the user

L means list

R for deletion

3.crontab specific format

Crontab-e-u root creates scheduled tasks for root users

Crontab-l-u root lists the scheduled tasks for root users

Crontab-r-u root removes scheduled tasks for root users

4.crontab time representation

What day is the day and month in minutes?

Every minute

/ 2 *

Every two minutes

/ 2 09-17

7 am-5 pm every two minutes

/ 2 / 2 *

Every two hours and every two minutes

* / 2 09-17 3 5 1

Every Thursday in May and March 1st

/ 2 09-17 * 5

Every Friday, 9: 00 a.m. to 5: 00 p.m.

Note: the relationship between the last day of the week and the sun and moon

5.

1 > systemctl status crond.service,systemctl start crond.service (this service must be enabled)

2 > crontab-e-u root creates scheduled tasks for root users

3 > come out a vim editor, and then write the format of the task to be scheduled as above

4 > crontab-l-u root lists scheduled tasks for root users

5 > cat / var/spool/cron/root you can see scheduled tasks in this file

6 > crontab-r-u root deletes scheduled tasks for root users

7 > rm-rf / var/spool/cron/root

4. Management of temporary files in the system

The command systemd-files needed to regularly clean up the system files finds the directory / usr/bin/systemd-tmpfiles where the files are located

Execute rpm-qf / usr/bin/systemd-tmpfiles to find the installation directory to install the package

Systemd-208-11.el7.x86_4

Execute rpm-ql systemd-208-11.el7.x86_4 to find the directory location / usr/lib/tmpfiles.d move to / usr/lib/tmpfiles.d

Edit the file vim tmp.conf

Edit file d / mnt/tmp 1777 root root 8s

Perform operations on files longer than 8s under / mnt/tmp/

Pwd view current location vim westos.conf edit westos file systemd-tmpfiles-- create / usr/lib/tmpfiles.d/xx.conf establish the file you just edited

Cd / mnt/ switch to / mnt/ to view the file you just created

Cd tmp/ switches to the file.

Touch file creates a new file

Systemd-tmpfiles-clean / usr/lib/tmpfiles.d/xx.conf

# the service in the system will generate temporary files when it is running normally

/ usr/lib/tmpfiles.d/xx.conf # # configuration of temporary files in the system

File type file name file permissions file owner file all group file existence time

D / mnt/westos 777 root root 10s

Systemd-tmpfiles-create / usr/lib/tmpfiles.d/xx.connf # # perform temporary file configuration

Systemd-tmpfiles-clean / usr/lib/tmpfiles.d/xx.conf # # temporary files in Qingli

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report