In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the Linux users how to implement custom at, cron planning tasks, the article is very detailed, has a certain reference value, interested friends must read it!
There are two kinds of scheduled tasks in Linux system, one is to execute at scheduled tasks only once, and the other is cron scheduled tasks that can be executed periodically.
At schedule tasks at one time
Description
Execute a specific command (single time) at a specified time, also known as a deferred action task.
Usage
At time [enter]
Parameters.
At-l # lists single scheduled tasks at-r tasks id # # tasks for deleting this id at-d tasks id # # tasks for deleting this id at-m # Let commands with no output generate mail at-M # Let commands with output generate messages at-c tasks id # # see actions for this id task at-f file # # use commands recorded in the file as commands for deferred task execution
Example
Check the system time first
[root@test ~] # dateThu May 17 18:40:11 CST 2018
Specify a single scheduled task (defer 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 > # # Command input ends, press Ctrl+D to exit job 10 at Thu May 17 18:45:00 2018 # # the system prompts for the scheduled task number 10
Cron periodically schedule tasks
To plan tasks using cron, you need to ensure that the crond service is turned on and self-booting.
# systemctl start crond# systemctl enable crond
Description
Maintain periodic scheduled task files for each user.
Usage
Crontab [- u user] [- l |-r |-e]
Option
Parameter usage-u specifies the user of the scheduled task. If you do not add-u, the default is the current user-l view scheduled task-r delete scheduled task-e edit scheduled task-I use-r to delete scheduled task, ask the user to confirm deletion
Corn scheduled task format
Item 1, item 2, item 3, item 4, item 5, item 6, time-sharing day, month and week order 00~5900~231~311~121~7action
If you need to specify a time period, you can use a horizontal bar (-) for a continuous period of time, a comma (,) for several discontiguous times, an asterisk (*) for all times, and a division sign (/) for intervals.
Example
[root@test ~] # crontab-e00 20 * rm-fr / tmp/* # # every day 20:00 delete all contents in / tmp 5 * * rm-fr / tmp/* # # 20:00 on the 1st and 5th of each month, delete all contents in / tmp 00 20 1-5 * * rm-fr / tmp/* # # 20:00 from the 1st to 5th of each month Delete all content in / tmp 00 20 1 fr 5 3 * rm-fr / tmp/* # # 20:00 on March 1 and 5, delete all content in / tmp 5 3 rm-fr / tmp/* # # and all Wednesday in March at 20:00, delete all content in / tmp 58 20-21 * rm-fr / tmp/* # # 20-21:00 every day, 58 minutes per hour Delete everything in / tmp * / 30 20-21 * * 1-5 rm-fr / tmp/* # # from 20:00 to 21:00 from Monday to Friday, every half hour, delete everything in / tmp 00 * / 3 * who # # check user login every 3 hours on the hour
Cron scheduled task permissions
In order to control users to define their own scheduled tasks at will, administrators can carry out ACL access control. The control files for at scheduled tasks are / etc/at.allow and / etc/at.deny, respectively, and the default at.llow does not exist. The control files for cron scheduled tasks are / etc/cron.allow and / etc/cron.deny, respectively, and the default cron.allow does not exist.
The above is all the contents of this article entitled "how users perform custom at and cron scheduling tasks in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.