Processes in Linux for scheduled task management

Source: Internet
Author: User
Tags set time system log terminates rsyslog

Process and scheduled task management

    1. The relationship between procedures and processes
      Program: Save executable code and data in hard disk, CD 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 according to specific conditions
      4): Pstree command: List 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: Suspend the current process, that is, into the background and stop 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 combination: 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; Scheduled tasks must be scheduled after the current system time.
Service script name:/ETC/INIT.D/ATD; format: at [hh:mm] [YYYY-MM-DD]
2): crontab command: According to 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): Manage 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: The root user can manage scheduled tasks for a specified user;

    1. A special method of representing time values
      • Represents any time in 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 1-5 weeks to Friday daily 17:00
        8 1,3,5 Weekly One, three or five 8:30
        0 8-18/2 between 8 and 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 message/var/log/messages
      Scheduled Task/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
Unified management by System service RSYSLOGD
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

    1. 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): Timely backup and archiving.
2): Extended Log retention period
3): Control log access: The log may contain all kinds of sensitive information, such as account, password, 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): Failure phenomenon: Unable to find boot program, start interrupt, cannot load operating system, black screen after boot
3): Solve the idea: the backup file should be prepared in advance, boot into the first aid mode with the RHEL 6 installation CD; Recover from backup files

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): Solve the idea: try to enter the boot command manually; Go to first aid mode, rewrite or restore from 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 account is available
3): Solution 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

    1. 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): malfunction: Unable to read or write data to 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

10. Disk Resource Exhaustion Failure
1): The cause of the failure: disk space has been a large amount of data occupied, space exhaustion, although there is still free space, but the number of files I node exhausted
2): Malfunction: 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

    1. Bad path exists in 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 disk, repair the hard disk, or replace the new hard drive

Processes in Linux for scheduled task management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.