Linux Set Timer task emptying log

Source: Internet
Author: User

Step 1: If the Linux server has Crond installed

timed tasks require support for Crond services
1. Start Method Service Crond Restart
2. The service is powered on by default
cancel scheduled task
Span style= "font-family:"comic sans ms", Sans-serif; Font-size:14px "> 1. Cancel all crontab-r
2. Cancel a crontab-e configuration file and delete which line of the row you want to cancel to configure
View currently there are those scheduled tasks
crontab-l

Step 2: Write a bash script, such as a simple script

#!/bin/bashtime=$ (date "+%y%m%d:%h-%m-%s") echo "${time}" echo "-I'm going to start cleaning up the logs-----" echo ">/opt/ Apache-tomcat-8.5.32.lop1/logs/catalina.outecho "---has been cleared---"

After writing, run it manually to see if it is correct.

Step 3: Add a Scheduled task

To open a scheduled task profile: CRONTAB-E
In the new window that pops up, tap I into writing:

* * * * * * xxx.sh

Or

* * * * * */opt/xxx.sh >>/xxx/xxx/crontab.log

Edit complete to save and exit

Step 4: View current Scheduled Tasks

Crontab-l

Linux Set Timer task emptying log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.