Crontab Shell script writes top information to file

Source: Internet
Author: User

The shell script in Crontab writes the top information to the file:


Note:

1, Top-n 1 for Execution 1 exit (default top is not exited),-D 1 for 1 seconds

2, crontab need to add/bin/bash


# CRONTAB-E

*/5 * * * */bin/bash/usr/local/bin/top.sh


# VI top.sh


#!/bin/bash


Date= ' Date +%y%m%d '

date2= ' Date +%y%m%d_%h%m '

date3= ' Date +%y%m%d-d ' 7 days ago '



echo "$Date 2" >>/log/top/$Date. Log

/usr/bin/top-b-D 1-n 1 | Head-n >>/log/top/$Date. Log

echo "" >>/log/top/$Date. Log

echo "" >>/log/top/$Date. Log

/bin/rm-rf/log/top/$Date 3.log

: Wq





This article is from the "Linux" blog, so be sure to keep this source http://yangzhiming.blog.51cto.com/4849999/1943268

Crontab Shell script writes top information to file

Related Article

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.