In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Shell background scheduled tasks when the use of crontab, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
The usage of crontab
Syntax: crontab [- u username] |-l |-r |-e |-v
-u: specify the user of crontab job
-l: lists the job of the current crontab
-e: use $EDITOR to edit crontab job
-v: lists the status of the current crontab job. Some shell may not support-v
Crontab file format:
Each line corresponds to one cron job
Each line is divided into six parts, each separated by a space and the same part separated by a comma
Minute hour day_of_month month weekday command
If * is used in the first five fields, it represents all the time steps
Minute:0-59
Hour:0-23 zero stands for zero.
Day_of_month:1-31
Month:1-12
Weekday:0-6 is 0 for Sunday, and 1-6 is for Monday to Saturday.
Command: script or command to be executed
$cat test_cron.sh
#! / bin/sh
# output system time to file time.txt
Echo `date` > > time.txt
# check the current cronjob, and the system indicates that the cronjob of the user habao is not used
$crontab-l
No crontab for habao
# add cronjob
$crontab-e
# not executed every other minute
# display the current system time # write it in the crontab file to make it easy to view the purpose of the scheduled job
* / home/habao/test_cron.sh
# check the current cronjob again
$crontab-l
# DO NOT EDIT THIS FILE-edit the master and reinstall.
# (/ tmp/crontab.3285 installed on Thu Sep 22 16:28:40 2011)
# (Cron version-- $Id: crontab.c,v 2.13 1994-01-17 03:20:37 vixie Exp $)
# display the current system time
* / home/habao/test_cron.sh
# View the output file time.txt
$cat time.txt
Thu Sep 22 16:33:00 CST 2011
Thu Sep 22 16:34:00 CST 2011
Thu Sep 22 16:35:00 CST 2011
Thu Sep 22 16:36:00 CST 2011
Thu Sep 22 16:37:00 CST 2011
Thu Sep 22 16:38:00 CST 2011
Thu Sep 22 16:39:00 CST 2011
To modify the current cronjob, crontab-e
To delete the current cronjob, crontab-r
After reading the above, have you mastered how to use crontab in shell background scheduled tasks? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.