Scheduled tasks under linux – scheduled tasks that are executed only once – linux operation and maintenance

Scheduled tasks are a very good function provided by the operating system. We often use scheduled tasks to deal with some things, such as regularly backing up website data every day, executing data statistics programs every month, and monitoring the operation of the server (when an error occurs Send a message to the administrator), etc., all of which need to be completed by timing tasks. The timing tasks under Linux are divided into two categories: timing tasks that are executed only once, and timing tasks that are executed periodically. Today, let’s take a look at the scheduled tasks that are executed only once. The scheduled tasks that are executed periodically will be described in the next article. atd service We use the at command to execute the scheduled task only once. If you want to execute the at command, you need to start the atd service first. Check the running status of the atd service and the command to open the atd service is as follows: # Check the status of the atd service # systemctl status atd # Enable atd service # systemctl start atd at permission management When using at to generate When creating a new task, the…

Scheduled tasks under linux – periodic scheduled tasks – linux operation and maintenance

The at command has been introduced in previous articles, which is used to set a scheduled task that is executed only once. Today, let’s take a look at the scheduled tasks that are executed periodically. In work, periodic scheduled tasks are often used, such as scheduled backup of system files, scheduled backup of database files, processing orders that have not been paid for a long time, and so on. Users set periodic crontab General users who want to set periodic scheduled tasks need to use the command crontab. Like at, crontab also has black and white lists, and the configuration files for them are – /etc/cron.deny, /etc/cron.allow. When the user sets a scheduled task, the task will be recorded in the /var/spool/cron directory as a text file. # ll /var/spool/cron/ total 4 -rw——- 1 root root 98 Jul 28 03:58 root About crontab, we only need to remember two commands crontab -e set scheduled tasks crontab -l view scheduled tasks The format for setting a scheduled task is as follows: Basic format: time-sharing date month week command Value range: [0-59] [0-23] [1-31] ​​[1-12] [0-7] In addition, we also need to remember a few special characters Meaning: * means any time…

A comprehensive explanation of the top command under linux – real-time monitoring of server status – linux operation and maintenance

The top command under linux can be used to monitor the health status of the server in real time. This command can obtain a lot of information, and it is one of the best helpers for server operation and maintenance engineers. We know that the ps command can monitor the running status of each process on the server at a certain moment. Compared with ps, the top command can continuously monitor. top [options] Common options are as follows: -d screen refresh interval, the default is 5 seconds -n total screen refresh times -u specifies the user name -p specifies the process ID Next, let’s look at the top command The generated information top – 14:55:21 indicates the current time of the system up 12 days, 1:28 indicates the time the server has been running since the last startup 1 user How many current systems are there users have logged in load average: 0.17, 0.09, 0.13 indicates the workload of the system in the past 1 minute, 5 minutes, and 15 minutes. Load means that the system is running several programs at the same time. For a single-core CPU, it is normal if the load is less than 1. If there…

linux下的系统服务介绍——init、systemd-linux运维

我们经常会听到服务service以及daemon这两个词,它们到底是什么意思呢?之间有什么区别和联系吗。linux下的服务service是常驻在内存中的程序,并且能够提供一些系统或网络方面的功能。而daemon从字面翻译是守护进程或后台进程的意思。所以阿,service和daemon你可以将它们看成是一个东西,不用去区分它们。 早期init管理机制 centOS6的时候,还是采用init的服务管理机制。这里稍微介绍下,因为有些东西在centOS7中还是可以使用的。主要看下面几个特点: 服务的启动、关闭以及状态查看等 启动服务: /etc/init.d/nginx start 重启服务: /etc/init.d/nginx restart 关闭服务: /etc/init.d/nginx stop 状态查看: /etc/init.d/nginx status 服务启动方式 独立启动:大部分的服务都是采用该模式,比如常见的mysqld、php-fpm、nginx、httpd等服务。 被super daemon托管启动:这些服务的启动是由另一个服务来托管,托管这些服务的服务我们成为super daemon,常见的supuer daemon有inetd、xinetd 执行等级 linux上有7个执行等级,分别是0、1、2、3、4、5、6。常用的有 1单人维护模式 3纯文本模式 5图形模式 各个执行等级的启动脚本是通过/etc/rc[0-6].d/SNNdaemon链接到/etc/init.d/daemon。 ll /etc/rc3.d/S55nginx lrwxrwxrwx 1 root root 15 Sep 21 11:30 /etc/rc3.d/S55nginx -> ../init.d/nginx S表示启动的意思,NN表示的是数字,这些数字表明了脚本的执行顺序,数字越小越先被执行。这个执行顺序可以很好的管理服务的依赖性关联。 开机自启服务 开机自启动:chkconfig on deamon 关闭开启自启动:chkconfig off deamon 查看服务是否已启动:chkconfig –list daemon systemd管理机制 自centos7以后,就弃用了之前的init管理机制,改用了systemd。下面我们来看看systemd管理有什么不一样的吧。 平行处理所有服务,加快开机流程。 和init一项一项去启动服务不同的是,systemd可以同时启动许多服务。所以,这样会大大加快开机等待时机。 解决服务相关性依赖 比如说要启动B服务必须要先启动A服务,这个时候,用systemd去启动B服务,它会自动检查依赖性,然后在启动B服务前先启动A服务。 unit类型 和init只有两种启动方式的stand alone、super daemon相比,systemd定义了一个统一的服务单位(unit),unit又分为:service, socket, target, path, snapshot, timer等多种类型。 向下兼容init的服务脚本 旧的/etc/inid.d/下面服务启动脚本,也是可以通过systemd去管理的。注意:若以手动方式启动/etc/init.d目录下的服务启动脚本,那么systemd是不能检测到该服务的运行状况的。 # systemctl status mysqld ● mysqld.service – LSB: start and stop MySQL Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: active (running) since Wed 2020-10-28 13:26:53 CST; 1 weeks 5 days ago …… # /etc/init.d/mysqld restart Shutting down MySQL…. [ OK ] Starting MySQL. [ OK ] [root@lijia ~]# systemctl status mysqld ● mysqld.service – LSB: start and stop MySQL Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: active (exited) since Wed 2020-10-28 13:26:53 CST; 1 weeks 5 days ago …… 关于init与systemd,我们需要重点掌握systemd,对于init也是需要去了解的。 以上就是linux下的系统服务介绍——init、systemd的详细内容,更多请关注 1024programmer.com 其它相关文章!

Linux operation and maintenance through systemctl management service-linux operation and maintenance

Since centOS7, a command for managing services has been added – systemctl, through which the services on the system can be managed very conveniently. Open and close the service through systemctl The following lists the relevant options for opening and closing the service start open the service stop shuts down the service restart restarts the service status checks the service status reload reloads the configuration file (without shutting down the service) enable starts the service at boot disable turn off self-starting at boot Learn through the following cases # View service operating status # systemctl status atd ● atd.service – Job pooling tools Loaded: loaded (/usr/lib/systemd/system/atd.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2020-11-07 16:20:59 CST; 3 days ago Main PID: 3002 (atd) CGroup: /system.slice/atd.service └─3002 /usr/sbin/atd -f Nov 07 16:20:59 iz8vb626ci0aehwsivxaydz systemd[1]: Started Job spooling tools. Nov 07 16:20:59 iz8vb626ci0aehwsivxaydz systemd[1]: Starting Job spooling tools… Through the information shown above, we can get a lot of information. From the second line Loaded, enabled appears to indicate that the service starts automatically after booting. From the running of the third line, we know that the service is running. Let’s demonstrate closing and starting services # systemctl stop atd…

Log files for linux operation and maintenance – common log files, services for managing log files – linux operation and maintenance

Almost all services on linux have log files, and the log files are used to record the running status of the software. Through log files, we can obtain a lot of useful information. For example, through nginx log files, we can count the number of daily IPs and pvs of the website. In addition, if there is a problem with the software operation, we can also locate the source of the error through the log file information. Therefore, the log file is also an important part of the software. Common log files In the Linux system, they are recorded in the /var/log/ directory There are many useful log files. /var/log/cron records information related to scheduled tasks /var/log/dmesg boot kernel information /var/log/btmp records error login information, this file cannot be viewed through vi, you can use the lastb command to view . /var/log/lastlog records the last login of each user, this file cannot be viewed through vi, use the lastlog command to view /var/log/maillog records mail information /var/log/message records important information of the system /var/log/recure Record verification and authorization information, as long as the program involves account and password will be recorded /var/log/wtmp Permanently record user login , Exit information, in…

logrotate log rotation for linux operation and maintenance – rotate nginx logs – linux operation and maintenance

There is a very useful rotation service on the linux system – logrotate. Through this service, log files can be managed in rotation. When the log file is too large, it can be cut into multiple small log files, and can also be compressed. The default log files access.log and error.log of nginx will not be rotated by themselves. Therefore, logrotate is often used to manage nginx logs in rotation. logrotate For the operation of the logrotate program, it is executed daily in the scheduled task of the system. # cat /etc/cron.daily/logrotate #!/bin/sh /usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status … Next, let’s take a look at the logrotate configuration file /etc/logrotate.conf. # View more information through man logrotate # The following is the default configuration weekly <=== defaults to rotate once a week rotate 4 <=== save 4 log files by default create <==== When the rotation is complete, create a new log file dateext <=== add the date before the rotated file name for easy management #compress <=== By default, the rotated files are not compressed. If you want to compress, remove # #Load the files in the /etc/logrotate.d directory include /etc/logrotate.d # The following are the rules for the rotation of…

Some common commands for setting network parameters in linux-linux operation and maintenance

Here are three commands related to network settings: ifconfig: query, set network card and ip, subnet mask, etc. Parameters (need to install the net-tools tool first) ifup, ifdown: start and close the network interface route: view 、Configure routing information ifconfig First look at the ifconfig command ifconfig [network card name] [options] up, down: enable or disable the network interface mtu: set the mtu value netmask: Set the subnet mask broadcast: Set the broadcast address First look at the first example, to view all network cards on the system, just enter the ifconfig command without adding any parameters # ifconfig eth0: flags=4163 mtu 1500 inet 192.168.2.220 netmask 255.255.255.0 broadcast 192.168.2.255 inet6 fe80::1733:cf21:906d:57af prefixlen 64 scopeid 0x20 ether 00:0c:29:84:5b:d0 txqueuelen 1000 (Ethernet) RX packets 9946 bytes 10315936 (9.8 MiB) RX errors 0 dropped 3 overruns 0 frame 0 TX packets 2208 bytes 186213 (181.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 … From the output information of this command, we can get a lot of information, such as network card name, ip address, subnet mask, broadcast address, etc. Let’s continue to look at a few Example # Modify the ip address # ifconfig…

How to troubleshoot network failures in linux-linux operation and maintenance

If the company’s website cannot be opened, if it is because of network problems, how should you troubleshoot. For another example, if the remote connection tool cannot connect to the server or the mysql database, it may be due to network problems. In daily work or study, we often encounter various network problems (because computer networks are too complicated). Now let’s take a look at how to troubleshoot if there is a network problem with the linux server. ping First look at the ping command, which is a tool used to test whether two hosts can communicate normally. The object of ping can be either an IP address or a domain name. This command can be used in both linux and windows cmd mode. The method of use is the same. # ping -c 4 8.210.247.5 PING 8.210.247.5 (8.210.247.5) 56(84) bytes of data. 64 bytes from 8.210.247.5: icmp_seq=1 ttl=64 time=1.54 ms 64 bytes from 8.210.247.5: icmp_seq=2 ttl=64 time=1.48 ms 64 bytes from 8.210.247.5: icmp_seq=3 ttl=64 time=1.46 ms 64 bytes from 8.210.247.5: icmp_seq=4 ttl=64 time=1.48 ms — 8.210.247.5 ping statistics — 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 1.460/1.494/1.548/0.042 ms # ping -c 1 baidu.com…

Software firewall iptables under linux – view and clear rules, define default policies – linux operation and maintenance

A firewall is a way for users to restrict access to certain ip or users to their hosts. There are two types of firewalls, hardware firewalls and software firewalls. Software firewalls are mainly used to filter data packets, and hardware firewalls are mainly used to protect against malicious attacks and filter data packets, such as DDOS attacks. Here, let’s explain the software firewall under linux-iptables. iptables and firewalld Under centOS6, the default software firewall is iptables, and in centos7, it is firewalld. What is the connection between them? In fact, firewalld is a newly packaged software on the original iptables. When learning iptables, it is recommended to close firewalld first, and open iptables yum install iptables-services systemctl stop firewalld systemctl start iptables table and chain of iptables Different of iptables Tables represent different functions, there are 4 tables by default filter (filter) nat (address translation) mangle raw Under different tables, they have their own rule chains: filter (INPUT/OUTPUT/FORWARD) nat (prerouting/output/postouting) The meaning of these chains As follows: INPUT chain – incoming data packets apply the rules in this rule chain OUTPUT chain – apply the rules in this rule chain to outgoing packets FORWARD chain – apply the rules in…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索