Skip to content

Instantly share code, notes, and snippets.

@meinac
Created March 22, 2016 12:57
Show Gist options
  • Save meinac/18ba861bf8e1cc3d3625 to your computer and use it in GitHub Desktop.
Save meinac/18ba861bf8e1cc3d3625 to your computer and use it in GitHub Desktop.
AWS create cronjob for rake tasks
container_commands:
01_remove_old_cron_jobs:
command: "crontab -u ec2-user -r || exit 0"
test: '[ -n "$tier" ] && [ "$tier" = "worker" ]'
02_create_cron_command:
command: "echo '0 * * * * source /home/ec2-user/.bashrc && pushd /var/app/current && rake task_name' > /home/ec2-user/cron_command"
test: '[ -n "$tier" ] && [ "$tier" = "worker" ]'
10_run_cron_job:
command: "crontab -u ec2-user /home/ec2-user/cron_command"
test: '[ -n "$tier" ] && [ "$tier" = "worker" ]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment