In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "how to set Linux system tasks", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to set Linux system tasks" article.
System startup process
Start the computer's hardware (BIOS)
Read time
Select the corresponding startup mode (USB HDD EFI)
If it is a Linux system, go back to the / boot directory and boot the system
The computer system starts to boot and reads the initialization configuration file
Vi / etc/inittab
Controls the run-level runlevel of the computer at startup
0halt (shutdown) 1Single user mode (single user mode) 2Multiusername without NFS (multiuser mode, but no network status) FS-- > FileSystem3Full multiuser mode (multiuser full mode) 4unused (reserved mode) 5X11 (user interface mode) 6reboot (restart mode)
Id:3initdefault: default runlevel is 3
Start the corresponding services and components with runlevel=3
Start booting public components or services by default
Vi / etc/rc.d/rc.sysinit
Start loading services corresponding to runlevel
K: the service that needs to be turned off when shutting down
S: the service that needs to be enabled at startup
The numbers represent the order in which they are turned on or off
All files are soft links (shortcuts) with the address of / etc/init.
Vi / etc/rc3.d
When the startup is complete, all the services
System service
You can use the chkconfig command to view the services of the current virtual machine
By looking at it, we can see that different levels correspond to each service to determine the automatic startup of this boot.
After the boot is over, you need to use the service (CentOS6) Systemctl (CentOS7) command to control whether the service is on or off.
Boot self-starting service
Rc.local (when this file has the permission to execute, it will be executed automatically when it is powered on)
Give rc.local executive authority
Vi hello.sh
Give executive authority
Mkdir-p / usr/local/scripts
First create the folder where the script is stored
Create a script file in a folder
To add the absolute path to the script in the / etc/rc.d/rc.local file
Chkconfig
Reboot
Chkconfig-- add / etc/init.d/schoolntpdate.shcp schoolntpdate.sh / etc/init.d/chmod aquix schoolnptdate.shchmod Amurx rc.local
Revoke the execution permission of rc.local before starting the test
Create a boot script file
Vi boot ntpdate.shroupdate.shroupdateashbinbat bashstarting chkconfigconfl 2345 88 99#description:schoolntpdate.sh## boot synchronization time yum info ntp & & ntpdate cn.ntp.org.cn
Set the execution permission to it
Copy the script to the / etc/init.d directory
Add to service
Restart the server
Scheduled task
In the system service center, crond is responsible for periodic tasks
Systemctl status crond.service
Add a task and edit the current user's task list
Crontab-e
Edit task
Create a script to create a folder
Add scheduled tasks to create a folder every minute
#! / bin/bashdname= `date "+% Y%m%d%H%M%S" `mkdir-p ~ / $dname
Crontab-e # Editing scheduled tasks crontab-rvi / var/spool/mail/root
View current scheduled tasks
Systemctl restart crond.service star command timesharing, sun, month and week command the first column represents minutes 1: 59 every minute * or * / 1 represents hours 1: 23 (0 = 0 o'clock) the third column represents the date 1: 31 the fourth column indicates the month 1: 12, the fifth column identification number, the week 0006 (0 means Sunday) the sixth column indicates the command to be run *: means at any time, in fact means "every". Can represent 00-23 hours or 00-12 minutes per month or 00-59 minutes -: indicates a range, 00 17-19 * cmd, that is, the execution of the command at 17, 18, and 19 o'clock every day, is divided into periods, 30, 3, 19, 19, cmd, that is, every day at 3: 00 in the morning and 19: 21 at night, the execution of the command / n: division, can be regarded as division, * / 5 * cmd Execute 3021 * / usr/local/rc.d/Lighttpd restart# every five minutes. The example above means to restart apache45 4 1, 10, 10, 22 * * / usr/local/rc.d/Lighttpd restart# at 21:30 every night. Restart apache10 1 * * 6 apache10 0 / usr/local/rc.d/Lighttpd restart# at 4:45 on the 22nd. The above example shows that on Saturday, Restart apache0,30 18-23 * / usr/local/rc.d/Lighttpd restart# at 1:10 on Sunday. The example above indicates that apache0 23 * * 6 / usr/local/rc.d/Lighttpd restart# is restarted every 30 minutes from 18:00 to 23:0 every day. The example above indicates that apache* * / 2 * / usr/local/rc.d/Lighttpd restart# is restarted at 11:00 every Saturday. The example above shows that between 11:00 in the evening and 7 in the morning, the apache* 23-7 play 1 * / usr/local/rc.d/Lighttpd restart# is restarted every two hours. Restart apache0 21 4 * mon-wed / usr/local/rc.d/Lighttpd restart# every other hour the above example indicates that apache0 4 1 jan * / usr/local/rc.d/Lighttpd restart# is restarted on the 4th of each month and at 11:00 from Monday to Wednesday. The above example indicates that apache-- is restarted at 4:00 on January 1st (function description: shows the minutes and seconds of the year, month, day, hour) date "+% Y% m% d% H% M% S"
Restart crontab for the configuration to take effect
Through crontab-l
View the history of the task
Clear task
test
Check to see whether to create
Systemctl restart crond.service # restart takes effect crontab-l # View current scheduled tasks
Clear task
The above is about the content of this article on "how to set up Linux system tasks". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to 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.