当前位置:网站首页>20-Openwrt crond crontab
20-Openwrt crond crontab
2022-07-28 04:19:00 【Creator_ Ly】
crond and corntab All are busybox Next tool ,crond It's a background process , Read the parameters in the configuration file every minute , Perform the corresponding action .crontab Is a command line provided , You can add, delete, modify and check the configuration file . This timing function is very convenient for ordinary functions , Like every night 12 Click restart router .
1、openwrt Start the crond process
crond The startup parameters of are as follows :
Usually set -c Specify the file directory ,-l The log level
# crond -h
crond: invalid option -- h
BusyBox v1.22.1 (2022-03-14 17:26:20 CST) multi-call binary.
Usage: crond -fbS -l N -L LOGFILE -c DIR
-f Foreground
-b Background (default)
-S Log to syslog (default)
-l Set log level. 0 is the most verbose, default 8
-L Log to file
-c Working dir
openwrt In or out /etc/init.d/ There is cron Start the program , as follows
# cat /etc/init.d/cron
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
START=50
USE_PROCD=1
PROG=/usr/sbin/crond
validate_cron_section() {
uci_validate_section system system "${1}" \
'cronloglevel:uinteger'
}
start_service () {
[ -z "$(ls /etc/crontabs/)" ] && return 1
loglevel=$(uci_get "[email protected][0].cronloglevel")
[ -z "${loglevel}" ] || {
/sbin/validate_data uinteger "${loglevel}"
[ "$?" -eq 0 ] || {
echo "validation failed"
return 1
}
}
mkdir -p /var/spool/cron
ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
procd_open_instance
procd_set_param command "$PROG" -f -c /etc/crontabs -l ${loglevel:-5}
procd_close_instance
}
service_triggers()
{
procd_add_validation validate_cron_section
}
The startup process is as follows :
# ps | grep crond
27141 root 1528 S /usr/sbin/crond -f -c /etc/crontabs -l 5
stay system Modules can be added crond start-up log Level of , The default is 5
# cat /etc/config/system
config system
option zonename 'Asia/Shanghai'
option timezone 'CST-8'
option cronloglevel '4'
2、crontab Command to use
List the current default scheduled task list :
crontab -l
Delete the current default scheduled task list :
crontab -r
Modify the current default scheduled task list , It's really just using vi open /etc/crontabs/root File for editing
crontab -e
above crontab Command is actually a chicken rib , Direct use cat/vi View modification /etc/crontabs/root Just a file .
3、 Create a scheduled task
Format of planning task list :
[minute] [hour] [day of month] [month] [day of week] [program to be run]
The value range of each parameter is :
minute(0-59)
hour(0-23)
day of month(1-31)
month(1-12)
day of week(0-7,0 or 7 is Sun)
The value in each parameter can have 4 A kind of separator :
* Express arbitrarily
– Scope of representation
, Indicates to enumerate multiple values
/ Said every
for example :
Every night from Monday to Friday 23:30 Restart the system
30 23 * * 1-5 reboot
Every other day 10 Minute execution run.sh Script
*/10 * * * * date
Every day 14 spot -15 spot , And every day 20 Point to -21 spot , Every 15 Once per minute run.sh Script
echo "*/15 14,20 * * * date" >> /etc/crontabs/root
Task added to /etc/crontabs/root After inside , It won't take effect until the next minute , because crond The process executes every other minute , If you want to take effect immediately , Just restart crond Conduct /etc/init.d/crond restart
Linux crontab command :https://www.runoob.com/linux/linux-comm-crontab.html
边栏推荐
- [day03] process control statement
- [kinematics] simulation of orbital angular momentum based on MATLAB [including Matlab source code 1971]
- Do Netease and Baidu have their own tricks for seizing the beach AI learning machine?
- RT thread changes the print serial port (add other functions on the basis of BSP)
- Convert py file to exe executable file
- openpose的一些个人理解
- Un7.27: common commands of redis database.
- ServletContext、request、response
- 月薪28K学员 自动化测试经验分享
- 企业数字化建设“三不五要”原则
猜你喜欢

【无标题】

@Requiredargsconstructor annotation

STC timer is abnormal (how to modify the initial value, the timing time is 100ms)

Notes on writing questions in sword finger offer

《Intel Arria 10 Avalon-MM DMA Interface for PCI Express Solutions User Guide》文档学习
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

What is interface testing and its testing process

21 days, fat brother personally takes you to play oauth2

Go结构体

I did these three things before the interview, and the result was actually direct
随机推荐
null安全与异常
CV2. Threshold(), CV2. Findcontours(), CV2. Findcontours image contour processing
jdbc使用
[735. Planetary collision]
Adding DSP library to STM32F103 and its solution
【无标题】
7/27 (board) dyeing method to determine bipartite graph + find combination number (recursive formula)
The State Administration of market supervision exposes typical cases of food safety
40: Chapter 4: Development File Service: 1:fastdfs: (1): introduction to fastdfs;
《关于我写自定义cell这件事》
Notes to subject 2
Regression - linear regression
VAE generation model (with VAE implementation MNIST code)
网页源代码查看竟然有这么多方法!你都知道吗?
金仓数据库KingbaseES安全指南--5.2. 数据完整性保护
Remove screen cutting and copying restrictions
Network visualization: features of convolution kernel and CNN visualization (through the attention part of gradient visualization network)
【luogu P4590】游园会(DP套DP)
Combination of Oracle and Premier League statistics and presentation
The unsatisfied analysis of setup and hold timing is the solution