I run a Linux machine with 50+ hourly cron jobs of the format:
00 00 * * * /usr/bin/curl http://domain.com/page.php/reports | mail -s "domain.com report cron successful execution" [email protected]
The above cron:
How can I set these cron to use with AWS Lambda, as I do not want a separate server just for these cron jobs.
If this is possible, I can setup AWS SES to work with this.
To send email from a Lambda function using Amazon SES, do the following: 1. Create an AWS Identity and Access Management (IAM) policy and execution role for Lambda to run the API call.
Using multithreading in AWS Lambda can speed up your Lambda execution and reduce cost as Lambda charges in 100 ms unit.
For scheduling the CRON, you should use CloudWatch Events. You can set a CRON expression that will trigger the CloudWatch Event. This event can in turn trigger a Lambda function.
Your Lambda function can make HTTP calls using the oh so great requests
package. Instructions for deployment on Lambda here. You can also use the not so easy to use urllib2
module as an alternative to requests
if you don't want to package requests
with your Lambda function.
As for sending emails, AWS SES would be the easiest avenue. You can alternatively use the email
module, though I've never used it in the context of a Lambda function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With