


Schedule tasks to specify time points and execute one-time tasks that depend on the atd service
Mar 11, 2024 am 09:07 AMScheduled tasks are scheduled to be executed at once
At a specified time point, perform a one-time task
Depends on the atd service and needs to be started to implement the at task
The at queue is stored in the /var/spool/at directory
-V: Display version information
-l: List the jobs waiting to be run in the specified queue; equivalent to atq
-d: Delete the specified job; equivalent to atrm
-c: View specific job tasks
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># systemctl start atd</span> <span class="token namespace">[root@localhost ~]</span><span class="token comment"># systemctl enable atd</span> <span class="token namespace">[root@localhost ~]</span><span class="token comment"># at now +1min</span> at> useradd xwz at><span class="token comment"># Ctrl+D結(jié)束</span> job 1 at Thu Aug 27 15:35:00 2020 <span class="token namespace">[root@localhost ~]</span><span class="token comment"># atq</span> 1 Thu Aug 27 15:35:00 2020 a root <span class="token namespace">[root@localhost ~]</span><span class="token comment"># id xwz</span> uid=1000<span class="token punctuation">(</span>xwz<span class="token punctuation">)</span> gid=1000<span class="token punctuation">(</span>xwz<span class="token punctuation">)</span> 組=1000<span class="token punctuation">(</span>xwz<span class="token punctuation">)</span>
Whitelist: /etc/at.allow does not exist by default. Only users in this file can execute the at command
Blacklist: /etc/at.deny exists by default. Users in this file are denied the ability to execute at commands, while users not in the at.deny file can execute them
If both files do not exist, only root can execute the at command
Cycle scheduling execution cron user level
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># systemctl start crond</span> <span class="token namespace">[root@localhost ~]</span><span class="token comment"># systemctl enable crond</span> crond 進(jìn)程每分鐘會(huì)處理一次計(jì)劃任務(wù) <span class="token namespace">[root@localhost ~]</span><span class="token comment"># ls /var/spool/cron # 儲(chǔ)存位置</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># crontab -l # 列出當(dāng)前用戶所有計(jì)劃任務(wù)</span> <span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># crontab -r # 刪除當(dāng)前用戶計(jì)劃任務(wù)</span> <span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># crontab -e # 編輯當(dāng)前用戶計(jì)劃任務(wù)</span>
Time-sharing sun and moon worship commands
Basics of Log Management
rsyslogd: Most of the log records are related to system operations. Applications such as secure US Linux hosts, authentication sshd, su, scheduled tasks at, cronhttpd/nginx/mysql, etc. can record logs in their own way
tail/var/log/messages system main log file
tail-f/var/log/messages dynamically view the tail of the log file
tail/var/log/croncrond, the log generated by the at process
wCurrently logged in user/var/log/wtmp
tail/var/log/mysqld.logMySQL
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># rpm -qc rsyslog</span> <span class="token operator">/</span>etc<span class="token operator">/</span>logrotate<span class="token punctuation">.</span>d<span class="token operator">/</span>syslog <span class="token comment"># 日志輪轉(zhuǎn)(切割)相關(guān)</span> <span class="token operator">/</span>etc<span class="token operator">/</span>rsyslog<span class="token punctuation">.</span>conf <span class="token comment"># rsyslogd的主配置文件</span> <span class="token operator">/</span>etc<span class="token operator">/</span>sysconfig<span class="token operator">/</span>rsyslog <span class="token comment"># rsyslogd相關(guān)文件</span>
Log service name
cron(LOG_CRON) Log formed by system scheduled tasks cront and at
daemon(LOG_DAEMON) Logs related to each daemon process
ftp(LOG_FTP)Log generated by ftp daemon
syslog(LOG_SYSLOG) stores the log information generated by the syslogd service (even though the service name has been changed to reyslogdlinux installation, and many configurations still inherit the syslogd service, so the service name is not changed here)
logrotateLog rotation
logrotate就是拿來進(jìn)行日志輪替(也叫日志輪詢)的,也就是把舊的日志文件聯(lián)通并更名linux 計(jì)劃任務(wù)沒執(zhí)行,同時(shí)創(chuàng)建一個(gè)新的空日志文件拿來記錄新日志,當(dāng)舊日志文件超出保存的范圍時(shí)就刪掉。
注:針對(duì)任何日志文件(rsyslog日志、Nginx訪問或錯(cuò)誤日志)
logrotate本身不是系統(tǒng)守護(hù)進(jìn)程linux 計(jì)劃任務(wù)沒執(zhí)行,它是通過計(jì)劃任務(wù)crond每晚執(zhí)行
<span class="token namespace">[root@localhost ~]</span><span class="token comment"># cat /etc/cron.daily/logrotate</span>
主配置文件
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># vim /etc/logrotate.conf</span> weekly <span class="token comment"># 一周輪轉(zhuǎn)一次</span> rotate <span class="token number">4</span> <span class="token comment"># 保留4份日志,也就是說,如果進(jìn)行了5次日志輪替,就會(huì)刪除第一個(gè)備份日志</span> create <span class="token comment"># 主動(dòng)創(chuàng)建新的日志文件</span> dateext <span class="token comment"># 使用日期來作為文件名的后綴</span> <span class="token comment">#compress # 每次輪轉(zhuǎn)需不需要進(jìn)行壓縮</span> include /etc/logrotate.d <span class="token comment"># 導(dǎo)入其他應(yīng)用的日志輪轉(zhuǎn)規(guī)則</span> /var/log/wtmp <span class="token punctuation">{</span> <span class="token comment"># 以下參數(shù)僅對(duì)此目錄有效</span> monthly <span class="token comment"># 一個(gè)月輪轉(zhuǎn)一次</span> create 0664 root utmp <span class="token comment"># 輪轉(zhuǎn)后創(chuàng)建新文件,并設(shè)置權(quán)限</span> minsize 1M <span class="token comment"># 最小達(dá)到1M才會(huì)輪轉(zhuǎn)</span> rotate <span class="token number">1</span> <span class="token comment"># 僅保留一個(gè)日志備份。也就是只保留wtmp和wtmp.1日志</span> <span class="token punctuation">}</span> /var/log/btmp <span class="token punctuation">{</span> missingok <span class="token comment"># 如果日志不存在,則忽略該日志的警告信息</span> monthly create 0600 root utmp rotate <span class="token number">1</span> <span class="token punctuation">}</span>
The above is the detailed content of Schedule tasks to specify time points and execute one-time tasks that depend on the atd service. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The scheduled task is scheduled to execute atat at a specified time point at a time, and the one-time task depends on the atd service. It needs to be started to realize the at task. The at queue is stored in the /var/spool/at directory -V: Display version information -l: List the specified queue Jobs waiting to be run; equivalent to atq-d: delete the specified job; equivalent to atrm-c: view specific job tasks [root@localhost~]#systemctlstartatd[root@localhost~]#systemctlenableatd[root@localhost~]# atnow+1minat>useraddxwzat>#

Laravel is a popular PHP framework that provides great support for web application development. One of the powerful and useful features is LaravelTaskScheduling. This article will introduce how to use LaravelTaskScheduling to perform scheduled tasks. 1. What is LaravelTaskScheduling scheduled task? LaravelTaskScheduling is

With the rapid development of the Internet, more and more websites and applications need to perform some scheduled tasks and planned tasks in the background, such as data cleaning, backup, statistical analysis, etc. As a popular web development language, PHP also provides corresponding scheduled task and planned task technology. This article will introduce the scheduled task and planned task technology in PHP in detail. 1. Concept and usage scenarios of scheduled tasks 1.1 Concept Scheduled tasks refer to automatically executing some specified tasks or operations within a specified time point or time interval. 1.2 make

Most users don’t know what the scheduled power on and off setting method for windows 7 is. Specifically, win7 can be set to automatically shut down, but users don’t know how to set it up. In fact, it can be set by entering a simple code, and you need to use cmd to set it up. The following is an introduction to the actual Windows 7 timer power on and off setting method. Users can refer to it and set it up, which is very simple. What is the method to set the timer on and off of Windows 7? 1. Set automatic shutdown. In fact, it can only be done from within the capabilities of the system itself, i.e. entering the shutdown command in the action box. Open the menu bar and click Action. If not, just press the shortcut key to open it, win+r to open it. 2. For example, if we want to turn off the power after three hours

Timing tasks and planned task management of PHP and small programs With the continuous development of Internet technology, many websites and applications need to perform certain tasks regularly, such as data cleaning, data analysis, data synchronization, etc. In PHP and small program development, how to manage scheduled tasks and planned tasks is an important topic. This article will introduce how to use PHP and applets to manage timed tasks and planned tasks, and give corresponding code examples. Scheduled task management in PHP In PHP, we can use Cron to manage scheduled tasks.

How to implement scheduled tasks and scheduled tasks through the Webman framework? Webman is a lightweight web framework developed based on Go language. It provides a simple way to implement scheduled tasks and planned tasks. This article will introduce how to use the Webman framework to implement timed tasks and scheduled tasks, and provide corresponding code examples. Before using the Webman framework, you need to install Webman first. Webman can be installed with the following command: gogetgithub.com/he

We often see words that start a project. In fact, this is the scheduled task setting in our computer. When our computer starts, these scheduled tasks will start with the Win7 system. Some tasks may have to be started, but others don't. In this regard, we can set up these scheduled tasks. Let's see the detailed operation. 1. First, we can find the start menu bar on the computer. In the Start menu, we can see related options, find the Control Panel option and click to enter. 2. After entering the computer's control panel, we can see the system and security options. In the first row of the current page, click the button and open it. 3. After entering the system and security options of the computer control panel, we can find the administrative tools button at the bottom.

Yes,youcanrunacustomSQLscriptonascheduleusingNavicatbyutilizingitsbuilt-inSchedulerfeature.1.OpenyourdatabaseconnectionandgotoTools>CreateScheduler.2.NamethetaskandundertheActionstab,selectRunSQLFileorRunSQLStatement,thenspecifyyourscript.3.IntheS
