AWS | Crontab

A New Era

AWS | Crontab

Something that I’ve learnt but not mentioned is ‘crontab’ which is basically the scheduling solution for Linux and you can set a job to run every minute, hour, day of the month, month and day of the week.

To access crontab be logged in and elevate to root with ‘sudo su’ and the type ‘cd /etc’ and then ‘nano crontab’. This will open nano and you can then add as needed the scheduled jobs.

This can be seen in the below image:

Now as an example this can be used to send the memory information of an EC2 instance back to CloudWatch by adding the following line:

  • */1 * * * * root /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl –mem-util –mem-used –mem-avail

This is how it will look with the memory line added:

Once the lines have been added you need to save and exit back to the console. This can be done by pressing ‘CTRL X’ and pressing ‘Y’ and ‘Enter’.

This will now create in Cloudwatch a new ‘Custom Namespace’ which will have in it 1 entry called ‘Linux System’.

This isn’t just for EC2 but the same script can be installed on your on-prem estate which keeps all monitoring to a central holistic monitoring tool.

By default this will default to every 5 minutes unless you’ve got ‘detailed monitoring’ turned on.

Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.