In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to solve the Ubuntu crontab problem, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
1. Using the Ubuntu crontab-e command is relatively easy to use. Enter ~ # Ubuntu crontab-e directly
An editing window will open, and the * * line will be prompted for content format:
# m h dom mon dow command
Specific meaning: minute hour date month week command, in a certain month (mon) on a certain day (dom) or day of the week (dow) at a few minutes (m) execute a command (command), * means any time. For example: 3 * / home/meng/hello.sh is: execute the hello.sh script under / home/meng/ at 03:00 every hour. After saving, enter Ctrl+X to exit according to the prompts at the bottom of the screen, at this time you will be prompted whether to save, enter Y; prompt for a file name, and there is a temporary file name, because it is just a test, enter directly to save.
Note: after editing, restart the cron process: ~ # / etc/init.d/cron restart to observe the running results, you will find that hello.sh will be executed every other hour at 03: 00. When using this command, the worry is whether it will be executed smoothly after the system is rebooted. When I rebooted the system, I found that everything was fine, so I dismissed this concern. However, there is still a problem, in general, the server is logged in after reboot, and no user is logged in. So if I am not using my root account when I execute the Ubuntu crontab-e command, will it be executed smoothly after the system restart?
two。 Edit the Ubuntu crontab file Ubuntu crontab is located in the / ect/ folder, there is a detailed description of it on http://wiki.ubuntu.org.cn/CronHowto, but I don't know how to open the Ubuntu crontab file. If you haven't edited it, you can see something like this:
# / etc/ crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in / etc/cron.d. These files also have username fields, # that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * rootcd / & & run-parts-- report / etc/cron.hourly
25 6 * roottest-x / usr/sbin/anacron | | (cd / & & run-parts-- report / etc/cron.daily)
47 6 * * 7 roottest-x / usr/sbin/anacron | | (cd / & & run-parts-- report / etc/cron.weekly)
52 61 * * roottest-x / usr/sbin/anacron | | (cd / & & run-parts-- report / etc/cron.monthly)
Due to the limited knowledge of the script, the meaning of each command cannot be explained in detail. In line 10, the format of the contents of the file is also defined. You can see that there is one more user than when using the Ubuntu crontab-e command. It represents the user who executed the command, and if it is root, it indicates that it is the system user. So I added the following line:
3 * root / home/meng/hello.sh
The above is all the contents of the article "how to solve the Ubuntu crontab problem". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.