Script to run (log) top command after every few minutes using crontab (CPU utilization logs)

top -b -n 1 | head -17 >> /var/log/logging.txt
echo “=========” >> /var/log/logging.txt

Change the permissions to execute:
chmod 777 script1

Put a shell script in one of these folders: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly

If these are not enough for you, you can add more specific tasks eg. twice a month or every 5 minutes or… go to the terminal and type:

crontab -e

this will open your personal crontab (cron configuration file), so use to generate the crontab line and paste it under the file.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s