linux系统定时重启Timing reboot of Linux systemEmployed
Automatic restart at 1 a.m. every month at 3 a.m.
Steps are as follows:
1, login with root account;
2. Open the terminal window;
3, input "crontab -e""
4, press the Insert key.
5, enter "031 * * reboot""
6, press the ESC key.
7, input ": WQ", and then enter.
The above input can be checked through the"crontab-l" command.Data interchange for trade
Automatic restart at 3 a.m. every Monday
1, login with root account;
2. Open the terminal window;
3, input "crontab -e""
4, press the Insert key.
5, enter "03 * * 1 reboot""
6, press the ESC key.
7, input ": WQ", and then enter.
The above input can be checked through the"crontab-l" command.Timing reboot of Linux system
After using the SSH tool to successfully login the background,run the following command:
Crontab -e
Then insert the following content in the document as required:04***/sbin/reboot (04 means restart at four a.m. every day. . .03 means 3 a.m. . . )
After the WQ is saved, the following command is executed torestart the crond service
/etc/rc.d/init.d/crond stop
/etc/rc.d/init.d/crond start
Set up every Sunday morning zero 4 restart
04 * * sun /sbin/reboot
The first one is minutes
The second one is the hour
The third is the date
The fourth is the month
The fifth is week (0-6)
Linux timing reboot
Linux timing task system Cron entry (turn)
Just made a backup module, and then the teacher prompted thebest to add an automatic backup function, so study the Cronservice to come. Cron is a built-in service for Linux, but itdoes not automatically up and start and close this service inthe following way:
/sbin/service crond start / / start service
/sbin/service crond stop / / close service
/sbin/service crond restart / / restart service
/sbin/service crond reload / / reload configuration
You can also start this service automatically when the systemis started:
Add it to the end of the script at /etc/rc.d/rc. local:/sbin/service crond start
Now the Cron service is already in the process, we can use thisservice, Cron services provide the following interfaces foreveryone to use:
1. edit directly with the crontab command
The cron service provides the crontab command to set up the cronservice. Here are some of the parameters and instructions forthis command:
Crontab -u // set a user' s cron service, root users need thisparameter when executing this command.
Details of crontab -l / a cron service user list
Crontab -r / / delete no users cron service
Crontab -e / / edit a user' s cron service
For example, root looks at your own cron settings: crontab -uroot -l
For example, root wants to delete the Fred settings for cron:
crontab -u Fred -r
When editing the cron service, there are some formats andconventions for the editor, input: crontab -u root -eEntering the VI editing mode, the content of the editor mustconform to the following format: */1 * * * * ls > /tmp/ls.txtA part of this format is the time setting, the back part is thecommand to execute the command to execute, if too much, can putthese commands into a script, then here directly call thisscript can be invoked, remember to write the full path to thelife. Time setting we have a certain agreement, the first fivenumbers on behalf of five numbers, the number of values andmeaning are as follows:
M i nu t e s (0-59)
Hour (0-23)
Date (1-31)
Month (1-12)
The week (0-6) //0 stands for Sunday
In addition to digital and some special symbols is "*" and "/"and "-", "*", representing the range of all the numbers, "/"representative of eachmeaning, "*/5" said each of the 5 units,"-" representatives from a number to a number, ", " separateseveral discrete numbers. Here are a few examples of the
problem:
At 6 a.m. every morning
06 * * * echo "Good morning. /tmp/test.txt" > > / / / / echoonly, do not see any output from the screen, because the cronoutput email to root any mail.
Every two hours
0 */2 * * * echo "Have a break now. " /tmp/test.txt
Between 11 in the evening and 8 in the morning, every two hours,eight a.m.
0 23-7/2, 8 * * * echo "Have a good dream:" /tmp/test. txt4 of the month and 11 Monday of each week to Wednesday morning0114 * 1-3 command line
At 4 a.m. in January 1st
0411 * command l ine
Every time you finish editing a user' s cron settings, cronautomatically generates a user with the same name in the/var/spool/cron file, the user' s cron information is recordedin the file, the file can not be edited directly, can onlyusecrontab -e to edit. After the cron starts, read the file onceevery clock and check if it' s going to execute the commands.
Therefore, this file does not need to restart the cron serviceafter modification.
2. edit /etc/crontab file configure Cron
Cron services not only read all the files in /var/spool/crononce a minute, but also read /etc/crontab once, so we canconfigure this file to do some things using Cron services. Thecrontab configuration is for one user, and editing the/etc/crontab is for the system task. The file format of thisfile is:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root / / if an error occurs, or the data output, dataas a mail sent to this account
The path HOME=/ / / users run, here is the root directory# run-parts
01****root run-parts/etc/cron.hourly//per hour performedwithin the /etc/cron.hourly script
024 * * * root run-parts /etc/cron.daily / / day performedwithin the /etc/cron.daily script
224*0*root run-parts/etc/cron.weekly//per week performedwithin the /etc/cron.weekly script
4241**root run-parts/etc/cron.monthly///etc/cron.monthlyto execute the script within a month
Notice the "run-parts" parameter, and if you remove thisparameter, you can write a script name that you want to run,instead of the folder name.
It' s actually modifying the /etc/crontab file
224 * * 0 root /sbin/reboot
Virmach对资源限制比较严格,建议查看TOS,自己做好限制,优点是稳定。 vCPU 内存 空间 流量 带宽 IPv4 价格 购买 1 512MB 15GB SSD 500GB 1Gbps 1 $7/VirMach:$7/年/512MB内存/15GB SSD空间/500GB流量/1Gbps端口/KVM/洛杉矶/西雅图/芝加哥/纽约等 发布于 5个月前 (01-05) VirMach,美国老牌、稳...
数脉科技怎么样?数脉科技品牌创办于2019,由一家从2012年开始从事idc行业的商家创办,目前主营产品是香港服务器,线路有阿里云线路和自营CN2线路,均为中国大陆直连带宽,适合建站及运行各种负载较高的项目,同时支持人民币、台币、美元等结算,提供支付宝、微信、PayPal付款方式。本次数脉科技给发来了新的7月促销活动,CN2+BGP线路的香港服务器,带宽10m起,配置E3-16G-30M-3IP,...
bgp.to在对日本东京的独立服务器进行6.5折终身优惠促销,低至$120/月;对新加坡独立服务器进行7.5折终身优惠促销,低至$93/月。所有服务器都是直连国内,速度上面相比欧洲、美国有明显的优势,特别适合建站、远程办公等多种用途。官方网站:https://www.bgp.to/dedicated.html主打日本(东京、大阪)、新加坡、香港(CN)、洛杉矶(US)的服务器业务!日本服务器CPU...