Regularly retrieve process memory and write logs

Source: Internet
Author: User

Regularly retrieve the process memory and write the log Shell code www.2cto.com $ cat mem. sh #! /Bin/bash LOGFILE = "/xxx/mem. log "date + % Y-% m-% d" "% H: % M: % S >>$ LOGFILE ps aux | grep 'bin/eas. py' | awk '{if ($13 ~ /^ \ W + $/) {print $13, $4} '>>$ LOGFILE $ crontab-l */1 *****/xxx/mem. sh $ crontab-e # edit $ crontab-r # Delete the crontab domain to run the job at a specific time, you need to understand the meaning and format of each domain in each entry of the c r o n t a B file. The following are the fields: minute 1-minute in column 1st ~ 5 9 2nd columns hour 1 ~ 2 3 (0 indicates midnight) 3rd columns 1 ~ 3 1 4th columns Month 1 ~ 1 2 5th columns day of week 0 ~ 6 (0 indicates Sunday) 6th column command Shell code to run 1. $ crontab-l 2.0 * ps aux | grep 'bin/eas. py' | awk '{if ($13 ~ /^ \ W + $/) {print $13, $4} '> "/xxx/mem. log", which runs directly behind crontab

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.