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

Supplement of scheduled tasks under linux (script)

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

Share

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

1. Title

Run the systemctl restart network command from 09:00 to 12:00 every night

00 21-00 * systmmctl restart network error, because the range is 0-2300 21-23 systmmctl restart network right

Run the systemctl restart network command every 2 hours and 22:00 every day from 7 a.m. to 12:00

00 07-12 bat 2jue 22 * systmmctl restart network

2. the format of the planned task. Errors will be reported if the format is wrong, but will not be reported if the command is wrong.

3. Topic: script

Pack the backup / etc/ directory to / tmp at 12:00 every evening (step)

# 1st milestone-Command Line Test (Test whether the command is ok)

# milestone 2-write and test scripts

# 3rd milestone-write scheduled tasks to perform checks every minute

# 4th milestone-write scheduled tasks to modify the time as required, decompress and check whether the contents of the compressed package are complete

Step 1:

Tar xf-C directory specified to extract to the specified directory

Step 2: copy and paste the successfully executed command from the command line into the script and test

Step 3: write crontab-eMagneCrontab-l to view the contents of scheduled tasks.

Scripts in scheduled tasks must use absolute paths. Tail-f / var/log/cron is the same as backing up files under ls / tmp.

Decompress to see if the content is normal.

4. Sh-x view the execution process of the script, and the more plus signs, the more priority the execution, and troubleshoot the errors of the script.

Command error

5. Timed task maxim

a. Be sure to add comments B. When writing scheduled tasks. Try to use the script C. Run the script using sh

6. add to the timing task: direct the wrong and correct information to the black hole or file, only 2 to choose 1, otherwise the system will not be able to recognize and execute

7. Scheduled tasks all the information displayed on the screen will be appended to the mailbox of root

Such as echo {01... 100} or tar when the prompt is removed, these contents will not be displayed on the screen, but will only be emailed to the root mailbox and displayed in / var/spool/mail/root.

8. Failure case: it will cause the inode number to be full.

9. Ultimate challenge:

1. Pack the backup / etc/ directory to the / backup/ip address named directory at 12:00 every evening to delete the backup 7 days ago, but keep the backup 1 per week.

Vim / serverActionScriptsUniverse kobe.shemanxinxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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