right now, we have a single server with a cronjob tab that sends out daily emails. We would like to scale that server. The application is standard zend framework application deployed on centos server in amazon cloud.
We already took care of the load balancing, content management and managing deployment. However, the cronjob is still an issue for us, as we need to grantee that some jobs are performed only once.
For example, the daily emails cronjob must only be executed once by a single server. I'm looking for the best method to grantee only one server will execute it only once.
I'm thinking about 2 solutions, but i was wondering if someone else had the same issue.
Both these solutions have advantages and disadvantages, and i was wondering if someone thought about someone else that might help us here.
Cron jobs aren't designed for the cloud. If the machine image holding your cron job scales out to 20 instances, your cron job will be executed 20 times more often. This is fine if the scope of your cron job is limited to the instance itself, but if the scope is larger, the above becomes a serious problem.
You can use two options to set multiple commands in the same cron job. 1. Use the &&: the double ampersand specifies that the second command should only run if the one before it is successful.
Cron jobs are typically located in the spool directories. They are stored in tables called crontabs. You can find them in /var/spool/cron/crontabs. The tables contain the cron jobs for all users, except the root user.
What does * mean in Cron? The asterisk * is used as a wildcard in Cron. * sets the execution of a task to any minute, hour, day, weekday, or month.
When you need to scale out cron jobs, you are better off using a job manager like Gearman
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