How to customize at and cron scheduled tasks in Linux

How to customize at and cron scheduled tasks in Linux

There are two types of scheduled tasks in Linux system, one is the at scheduled task which will only be executed once, and the other is the cron scheduled task which can be executed periodically.

at One-time scheduled tasks

describe

Execute a specific command (single time) at a specified time, also called a delayed action task.

usage

at time [Enter]

parameter

at -l #List single scheduled tasks at -r task id ##Delete the task with this id at -d task id ##Delete the task with this id at -m #Make the command without output generate email at -M #Make the command with output generate email at -c task id ##View the action of the task with this id at -f file ##Use the commands recorded in the file as the execution commands of the delayed task

Examples

First check the system time

[root@test ~]# date
Thu May 17 18:40:11 CST 2018

Specify a single scheduled task (delayed action)

[root@test ~]# at 18:45 ##Plan executed at 18:45 on the same day (18:45 2018-05-17)
at> date ##Scheduled task content at> shutdown -h now ##Scheduled task content at> <EOT> ##Command input ends, press Ctrl+D to exit job 10 at Thu May 17 18:45:00 2018 ##The system prompts that there is a scheduled task numbered 10

Cron periodic scheduled tasks

To use cron to schedule tasks, you need to ensure that the crond service is enabled and starts automatically at boot.

# systemctl start crond
# systemctl enable crond

describe

Maintain a periodic cron job file for each user.

usage

crontab [ -u user ] [ -l|-r|-e ]

Options

parameter usage
-u Specify the user for the scheduled task. If -u is not specified, the current user is used by default.
-l View scheduled tasks
-r Deleting a scheduled task
-e Editing a scheduled task
-i When deleting a scheduled task using -r, the user is asked to confirm the deletion

corn plan task format

Item 1 Item 2 Item 3 Item 4 Item 5 Item 6
point hour day moon week Order
00~59 00~23 1~31 1~12 1~7 action

If you need to specify a time period, you can use a hyphen (-) to indicate a continuous period of time, a comma (,) to indicate several discontinuous periods of time, an asterisk (*) to indicate all periods of time, and a division sign (/) to indicate intervals of time.

Example

[root@test ~]# crontab -e
: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

Cron scheduled task permissions

To prevent users from arbitrarily defining their own scheduled tasks, administrators can implement ACL access control. The control files for the at scheduled tasks are /etc/at.allow and /etc/at.deny. By default, at.llow does not exist. The control files for cron scheduled tasks are /etc/cron.allow and /etc/cron.deny. By default, cron.allow does not exist.

The above article on how Linux users can customize at and cron scheduled task execution is all I have to share with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of using the at command for one-time scheduled tasks in Linux
  • Detailed explanation of how to use cron scheduled tasks in Linux
  • Brief discussion: Summary of commonly used symbols for Linux cron scheduled tasks
  • Introduction to scheduled tasks in Linux system

<<:  Simple writing of MYSQL stored procedures and functions

>>:  WeChat applet realizes taking photos and selecting pictures from albums

Recommend

...

Native JS to implement sharing sidebar

This article shares a sharing sidebar implemented...

How to use node to implement static file caching

Table of contents cache Cache location classifica...

HTML mouse css control

Generally speaking, the mouse is displayed as an u...

Ten Experiences in Web Design in 2008

<br />The Internet is constantly changing, a...

Talking about ContentType(s) from image/x-png

This also caused the inability to upload png files...

Convert psd cut image to div+css format

PSD to div css web page cutting example Step 1: F...

How to use MySQL binlog to restore accidentally deleted databases

Table of contents 1 View the current database con...

Introduction to html form control disabled attributes readonly VS disabled

There are two ways to disable form submission in ...

How to import txt into mysql in Linux

Preface When I was writing a small project yester...

Detailed usage of Vue timer

This article example shares the specific code of ...

HTTP header information interpretation and analysis (detailed summary)

HTTP Header Explanation 1. Accept: Tells the web s...