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

How to use the common command crontab in Linux

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to use the Linux command crontab, which is very detailed and has a certain reference value. Friends who are interested must finish reading it!

The Linux common command contab (cron table) command is used to manage the tasks that users need to perform periodically, similar to the scheduled tasks under Windows. When the operating system is installed, this service tool is installed by default, and the crond process is automatically started. The crond process checks every minute to see if there are any tasks to be executed, and if so, execute the task.

Syntax: crontab [- u user] file crontab [- u user] [- I] {- e |-l |-r}-u user: used to set a user's crontab service

File: file is the name of the command file, which means to load file as a task list file for crontab and load crontab

-e: edit the contents of a user's crontab file. If no user is specified, it represents the current user.

-l: displays the contents of a user's crontab file. If no user is specified, it represents the current user.

-r: delete a user's crontab file from the / var/spool/cron directory.

-I: give a confirmation prompt when deleting the user's crontab file.

The instance executes command every minute (because cron scans every 1 minute by default, so it is all *)

* * command executes command in the 3rd and 15th minutes of each hour

3Jing 15 * command executes command at the 3rd and 15th minutes of 8-11:00 every morning:

3 command 158-11 * command is performed every 3 and 15 minutes from 8 am to 11:00 every other day:

3Jing 158-11 * / 2 * * command executes command every Monday at the 3rd and 15th minutes from 8am to 11:00

3Jing 158-11 * * 1 command restarts smb at 21:30 every night

30 21 * / etc/init.d/smb restart restart smb at 4: 45 on the 1st, 10th and 22nd of each month

45-4-1-10-10-22 * * / etc/init.d/smb restart restart smb at 1: 10 every Saturday and Sunday

10 1 * * 6 smb / etc/init.d/smb restart restart smb every 30 minutes between 18: 00 and 23: 00 every day

0pr 30 18-23 * / etc/init.d/smb restart restart smb every hour

* * / 1 * / etc/init.d/smb restart restarts smb every other hour between 11:00 and 7am

* 23-7 etc/init.d/smb restart 1 * / smb restarts on the 4th of each month and at 11:00 from Monday to Wednesday

0 11 4 * mon-wed / etc/init.d/smb restart executes scripts in the / etc/cron.hourly directory every hour

0 1 * root run-parts / etc/cron.hourly above are all the contents of this article entitled "how to use Linux commands crontab". 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.

Share To

Development

Wechat

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

12
Report