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