Process and scheduled task management
1. Relationship of procedures and processes
programs: executable code and data stored on hard disk, CD-ROM and other media; statically saved code
Process: program code running in CPU and memory; code executed dynamically; parent, child process: each process can create one or more processes
Basic commands
1 ): PS Command ( Processes STATISTC ): view Static Process statistics
format: PS aux ; ps–elf
2 ): Top Command : View Dynamic process rank information
3 ): Pgrep command: query process PID information based on specific criteria
4 ): Pstree Command : lists process information in a tree-shaped structure
format:pstree–aup ;pstree–ap user
2. How the process starts
Manual start
Reception start (foreground, front desk): User input command, direct execution program
Background boot (background, background): Add "&" symbol at the end of the command line
[Email protected] ~]# cp/dev/cdrom Mycd.iso &
[1] 28454 ( output information includes background task serial number,PID number )
scheduled start
Use the AT command to set up a one-time scheduled task; Use the crontab command to set up recurring scheduled tasks
3. Pre-and post-process scheduling
1 ): Ctrl + Z key combination : Suspends the current process, which is called into the background and stops execution
2 ): Jobs Command : View a list of tasks in the background; format:jobs-l
3 ): FG command : Restore the background process to the foreground to run, you can specify the task sequence number
4. terminating the process
Ctrl + C key combinations : Interrupts the command being executed
Kill , Killall Command
Kill the process that terminates the specified PID number
Killall all processes used to terminate a specified name
-9 option to force termination
Pkill Command : terminates the corresponding process according to a specific condition
Common Command options: -u: Terminates the process according to the user name the process belongs to;-T: Terminates the process based on the terminal where the process resides
5. Planning Task Management
1 ): at Command : A one-time scheduled task, provided that the corresponding system service ATD must already be running, and that the scheduled task must be scheduled to execute after the current system time.
Service script name:/ETC/INIT.D/ATD; format:at[hh:mm] [YYYY-MM-DD]
2 ): crontab command : Follow the pre-set time period (minutes, hours, days ...). Executes the user-specified command operation repeatedly; service script name:/etc/init.d/crond
Main settings file
Global configuration file, located in file:/etc/crontab
system default settings, located in directory:/etc/cron.*/
User-defined settings, located in file:/var/spool/cron/user name
3 ): Management Cron Scheduled Tasks
Edit Scheduled Task:crontab-e [-u user name ]
View Scheduled Tasks:crontab-i [-u user name
Delete Scheduled Task:crontab-r [-u user name ]
Note: Root users can manage scheduled tasks for a given user , and regular users can manage only their own scheduled tasks
6. Special representation of time values
* Indicates any time within the range
, which represents multiple discontinuous points of time for the interval
-Represents a continuous range of time
/Specify the time frequency of the interval
Give me a chestnut.
0 17 * * 1-5 weeks to Friday daily 17:00
30 8 * * 1,3,5 per week, three or five 8:30
0 8-18/2 * * * 8 to 18 points every 2 hours
0 * */3 * * every 3 days
system failure Analysis and troubleshooting
1. log file Analysis
functions: used to record various events occurring in system and program operation, and to help diagnose and resolve system failures by reading logs
Analysis:
Kernel and System log: System service syslog Unified Management, log format basically similar
User log: Record the system user login and exit system related information
Program log: Log files that are managed independently by various applications, and the record format is not uniform
Save location : Default in:/var/log directory
Main log files:
Log |
Storage location |
Kernel and public messages |
/var/log/messages |
Scheduled Tasks |
/var/log/cron |
System boot |
/var/log/dmesg |
Mail system |
/var/log/maillog |
User Login |
/var/log/lastlog ; /var/log/secure ; /var/log/wtmp ; /var/run/btmp |
2. kernel and system logs
Service by System RSYSLOGD Unified Management
Package: rsyslog-5.8.10-8.el6.x86_64
Main program:/SBIN/RSYSLOGD
Configuration file:/etc/rsyslog.conf
level of log Messages
0 Emerg (Emergency): causes the host system to become unusable
1 alert (warning): A problem that must be taken immediate action to resolve
2 Crit (severe): more serious situation
3 ERR (Error): Run error occurred
4 WARNING (Reminder): Events that may affect system functionality
5 NOTICE (Note): Does not affect the system but is worth noting
6 info (Info): General information
7 Debug (Debug): Program or system debug information, etc.
General format of the log record
3. user log Analysis
Saved user login, exit system and other related information
/var/log/lastlog: Recent User logon events
/VAR/LOG/WTMP: User logon, Logoff and system on/off events
/var/run/utmp: Details for each user who is currently logged on
/var/log/secure: Security events related to user authentication
analysis Tools : Users, who, W, last, Lastb
4. Program Log Analysis
Managed independently by the appropriate application
Web services:/var/log/httpd/; Access_log, Error_log
Agent services:/var/log/squid/;access.log, Cache.log, Squid.out, Store.log
FTP Service:/var/log/xferlog
Analysis Tools:
Text viewing, grep filtering retrieval, viewing in the Webmin management suite
Text filtering and formatting editing tools for awk, SED, and more
Webalizer, Awstats and other dedicated log analysis tools
Note: Logs are not completely reliable, and smart hackers often clean the site after they invade the system.
5. Log Management policy
1 ): Backup and archive in good time
2 ): Extended log retention period
3 ): Control log Access : The log may contain sensitive information such as accounts, passwords, etc.
4 ): Centralized management of logs
Send the server's log files to a unified log file server
Facilitate the unified collection, collation and analysis of log information
Eliminate accidental loss, malicious tampering, or deletion of log information
6. repairing MBR sector failures
1): damage caused by virus, Trojan, etc. improper partition operation, disk read and write error operation
2 ): Malfunction : Unable to find boot program, start interrupt, cannot load operating system, black screen after boot
3 ): Solution : The backup file should be prepared in advance, boot into the first aid mode with the RHEL 6 installation CD, and restore from the backup file
7. fix GRUB boot Failure
1 ): Failure reason : The GRUB boot program in MBR is corrupted; grub.conf file is missing, boot configuration is incorrect
2 ): Symptom : System boot stalled, display "grub>" prompt
3 ): Workaround : Try entering the boot command manually, entering emergency mode, rewriting or recovering from a backup grub.conf
; Rebuilding the GRUB program to the MBR sector
8. forgetting the root user's password
1 ): Failure reason : Forgotten root User's password
2 ): Failure to perform administrative operations that require root privileges, and cannot log on to the system if no other accounts are available
3 ): Solving ideas
Method one: Boot into single-user mode, reset Password:grub > Kernel ... single or s or 1
Method Two: Enter the first aid mode, reset the password
9. Repairing the file system
1 ): Failure reason : Abnormal shutdown, sudden power outage, equipment read and write errors, etc. the file system's Super block (Super-block) information is corrupted
2 ): Failure to read or write data to the partition; prompt "Give root password for maintenance" after startup
3 ): Solve the idea : Enter the root password according to the prompt, enter the repair state; Use the fsck command to repair
Disk resource exhaustion Failure
1 ): The cause of the failure: disk space has been a large amount of data occupied, the space is exhausted, although there is still free space, but the number of files I node exhausted
2 : Symptom : Unable to write new file, Prompt "...: No space on Device", some programs cannot run, even system cannot start
3 : Solve the idea : Clean up disk space, delete useless, redundant files, transfer or delete trivial files that occupy a large number of I nodes, enter single user mode, first aid mode to repair; Set disk quotas for users
There are bad lanes in the disk device .
1 ): Failure reason : Bad channel (logical or physical) in disk device
2 ): Failure phenomena
The disk device makes an abnormal sound when it reads data from the disk.
Read repeatedly and error when accessing a file on disk, prompting for file corruption
Unable to complete formatting for newly created partition
The system frequently crashes when using this disk
3 : Solve the problem : detect if there is a bad path in the hard drive, repair the hard disk, or replace the new hard drive
Process and scheduled task management in Linux