In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Format writing
Common command
Crontab-e # opens editing scheduled tasks, just like using the vim tool
Crontab-l # View scheduled tasks
two。 Example
Execute / bin/ls once a month at the 0th minute of every hour
0 * / bin/ls
/ usr/bin/backup is performed every 3 hours and 0 minutes from 6 a.m. to 12:00 every December
0 6-12 beat 3 * 12 * / usr/bin/backup
Send a letter to alex@domain.name at 5:00 every afternoon from Monday to Friday
0 17 * 1-5 mail-s "hi" alex@domain.name
< /tmp/maildata 每月每天的午夜 0 点 20 分, 2 点 20 分, 4 点 20 分....执行 echo "haha" 20 0-23/2 * * * echo "haha" 下面再看看几个具体的例子: 0 */2 * * * /sbin/service httpd restart 意思是每两个小时重启一次apache 50 7 * * * /sbin/service sshd start 意思是每天7:50开启ssh服务 50 22 * * * /sbin/service sshd stop 意思是每天22:50关闭ssh服务 0 0 1,15 * * fsck /home 每月1号和15号检查/home 磁盘 1 * * * * /home/bruce/backup 每小时的第一分执行 /home/bruce/backup这个文件 00 03 * * 1-5 find /home "*.xxx" -mtime +4 -exec rm {} \; 每周一至周五3点钟,在目录/home中,查找文件名为*.xxx的文件,并删除4天前的文件。30 6 */10 * * ls 意思是每月的1、11、21、31日是的6:30执行一次ls命令 运行脚本实例# means to run the script every 1 minute. Note that the script path is written to determine the path and the script X should be given permission to run.
/ dev/null means to send all the output generated by the script, whether standard or incorrect, to the null device.
& finally, a & indicates running in the background. It is recommended to add & when writing a boot script.
3. View the log
Tail-f / var/log/cron # Monitoring log "/ var/log/cron" is the log path of crontab
As you can see from the log, the script is executed once in the first second of every minute.
4. 2 > & 1 several basic symbols and their meanings
/ dev/null indicates an empty device file
0 indicates stdin standard input
1 represents stdout standard output
2 indicates stderr standard error
For the understanding of 2 > & 1, 2 is standard error and 1 is standard output, so this command is equivalent to redirecting standard error to standard output.
In case 1, the redirect error is output to a file
Case 2 the standard error output is redirected to the file
Case 3 error output redirected to standard output
# nginx-V is error output, but grep does not handle error output, so it is more troublesome for us to find modules
# I changed the statement to output all the error output to the standard so that grep can handle it
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.