Last active
March 13, 2022 01:28
-
-
Save yuta-imai/5857793 to your computer and use it in GitHub Desktop.
With this user data script, you can set up cron job to put some custom metrics for CloudWatch at instance initiation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd /home/ec2-user | |
wget http://ec2-downloads.s3.amazonaws.com/cloudwatch-samples/CloudWatchMonitoringScripts-v1.1.0.zip | |
unzip CloudWatchMonitoringScripts-v1.1.0.zip | |
rm CloudWatchMonitoringScripts-v1.1.0.zip | |
chown ec2-user:ec2-user aws-scripts-mon | |
echo "*/5 * * * * ec2-user /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl --mem-util --disk-space-util --disk-path=/ --from-cron" >> /etc/crontab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks much for the info @Igawin. This works for me. :)
Also for whoever is trying to find related info and ending up here, using /var/spool/cron/ the user shouldn't be included in the syntax as it's already specified as the file name. Otherwise, the daemon will treat it as syntax error and ignore the task.