en
Language
  • en
  • cs
  • hu
  • de
  • fr
  • es
  • br
  • ru
  • kr
  • jp
AI translation
  • it
  • pl
  • tr

How to Configure Cron (v10 and Older)

Introduction

This guide explains how to configure cron for background task execution in Easy8 version 10 and older. Cron allows scheduled tasks to run regularly, such as sending notifications or triggering automated processes.

This article does not apply to Easy8 version 11 and newer or Docker-based deployments.

Target Audience

  • Administrator

Prerequisites

Before starting, ensure you have:

  • Easy8 version 10 or older
  • Access to the server as a non-root user (e.g., easy)
  • Correct file paths for your application directory and script

Do not run rake tasks as root. It may result in permission errors and failed task execution.

How to Configure Cron

Step 1: Check or Edit Crontab for the User

View current crontab entries for the easy user:

crontab -u easy -l

Edit the crontab for the easy user:

crontab -u easy -e

Apply changes after editing:

sudo service cron reload

Step 2: Create the Cron Script

Create a script file at:

/home/easy/scripts/easy_scheduler.sh

Script content:

#!/bin/bash -l

LOG_FILE="/home/easy/current/log/easy_scheduler_rake.log"

echo "$(date '+%Y-%m-%d %H:%M:%S') start rake" >> ${LOG_FILE}
cd /home/easy/current && bundle exec rake easyproject:scheduler:run_tasks RAILS_ENV=production >> ${LOG_FILE}
echo "$(date '+%Y-%m-%d %H:%M:%S') end rake" >> ${LOG_FILE}

Make the script executable:

sudo chmod +x /home/easy/scripts/easy_scheduler.sh

Step 3: Add Cron Schedule

To run the script every 5 minutes, add this line to the easy user’s crontab:

*/5 * * * * /home/easy/scripts/easy_scheduler.sh &> /dev/null

This will run scheduled rake tasks and save logs to:

/home/easy/current/log/easy_scheduler_rake.log

Conclusion

You have configured cron to run Easy8 background tasks automatically every 5 minutes. This setup is necessary only for versions 10 and earlier. Always ensure the script runs under the correct user and has proper execution permissions.

Related Topics and Further Reading

Try Easy8 in 30 days free trial

Access all features, SSL protected, no credit card required.