A program is a static collection of executable machine code and data stored on an external storage medium (such as a hard disk), and a process is a computer program that is in a dynamic state of execution on the CPU and in memory. In Linux, you can create one or more processes after each program is started.
PS command to view static process statistics
PS shows only the processes that are open in the current user session
PS aux displays process information in a simple list
Ps-elf display of process information in the system in a long format, including richer content
Top command to view process dynamic information
In the current terminal has an interactive interface to display the process ranking, timely tracking CPU, memory and other system resource consumption situation, the default every three seconds to refresh
P Key: Sort processes based on CPU usage
M key: Sort the process based on memory usage
N Key: Sort by start time
H key: Get the online Help information for Top program
Q Key: Exit Top Program
K Key: Enter the specified process PID number, press ENTER to terminate the corresponding process
Pgrep Command query specifies process information
-l display PID and corresponding process name at the same time
-U queries a specific user's process
-T queries a process running at a specific terminal (such as tty1)
Pstree command View the process tree structure, the corresponding relationship between the processes
-aup View the current process tree and include the PID number, user name, and full command information for the process
The-AP user name parameter only looks at the process tree structure of the specified user
Control process
Command +& Run the command in the background without occupying the command interface of the foreground
CTRL + Z suspends the current process, moves into the background and stops execution
Jobs view process tasks running in the background
-L also shows the PID number of the process
Bg+pid resume running the background paused task and continue running in the background
Fg+pid Restore the background paused task to the foreground run
Terminating Process Execution
CTRL + C Force interrupts a process that is executing in the foreground
Kill+pid terminates the process and exits normally
-9 forcing a process to terminate
killall+ process name terminates multiple processes with the same name in the system, which is more convenient and efficient
-9 Forced termination
The Pkill command terminates a specific process based on the name of the process, the user, the terminal, and other properties
-U terminates a process for a specific user
-T terminates a process running at a specific terminal (such as tty1)
Scheduled Task management
In the Linux operating system, you can also configure pre-scheduled system administration tasks (such as regular backups, periodic collection of monitoring data) at a specified time and on a specified date
At one-time task settings
Configuration file/etc/init.d/atd
Command format: at time date
For example: 20:00 on August 15, 2017 is the automatic shutdown system
# at 20:00 2017-8-15
At> Shutdown-h Now
At> Press Ctrl+d to submit a task after Setup is complete
ATQ command queries a scheduled task that has been set but not yet executed
The ATRM command deletes the at task with the specified number and will not be executed after deletion
Crontab Recurring Task Settings
Configuration file/etc/crontab
User Cron task configuration file storage directory/var/spool/cron
Command format: CRONTAB-E Edit scheduled Task List
-u specifies which user the managed scheduled task belongs to and defaults to its own
-l list Displays task schedules
-R Delete Scheduled Task list
1. Edit the Scheduled Tasks list
After executing CRONTAB-E, open the Schedule task editing interface
Edit format: minutes hours date Month Week command executed
* Indicates any time in the range of values
-Represents a continuous time range, such as "1-3" for 1, 2, 3
That represents the discontinuous range of an interval, such as "1,5" means 1,5
/indicates that the specified interval frequency, such as "*/12" in the hour field, represents every 12 hours
For example: Repeat the following system management tasks in a fixed cycle, as follows
1. 7:50 automatically open the sshd serviceevery morning, close at
2. Empty the FTP Server common directory every 5 days /var/ftp/pub
3. Restart the httpd service every Saturday
4. Package backup /etc/httpd directory when 17:30 per week, three or five
# crontab-e
7 * * */sbin/service sshd start
* * * * /sbin/service sshd stop
0 0 */5 * */bin/rm-rf/var/ftp/pub/*
7 * * 6/sbin/service httpd restart
* * 1,3,5/bin/tar zcf httpd.tar.gz/etc/httpd/
2. View the Task List
Crontab-l View the list of scheduled tasks for the current user
-U View other users ' scheduled tasks
Example: Viewing a user ysf scheduled task
# crontab-l-u ysf
3. Delete the user's Scheduled Tasks list
When you simply delete a scheduled task, you can edit it through crontab-e, and when you need to clear all the scheduled tasks for a user, you execute the crontab-r command
Example: Viewing a user ysf scheduled task
# crontab-r-u ysf
This article is from the "Yang Shufan" blog, make sure to keep this source http://yangshufan.blog.51cto.com/13004230/1950081
Linux Process Control and scheduled task management