How to Perform Cron Jobs on AccuWeb Cloud?

How to perform Cron jobs on our platform?

Cron is a time-based job scheduler that operates within Unix-like computer operating systems. It facilitates the scheduling and execution of jobs, such as commands or shell scripts, at specific dates and times according to predefined schedules. Users can rely on Cron to automate task execution and ensure timely job completion based on their specified schedule.

It is commonly employed to automate system maintenance or administration tasks, though its general-purpose design allows it to be used for other purposes, such as establishing connections to the Internet and email downloads.

The platform empowers you with the possibility to run your programs at a specified time with the help of cron, which receives your instructions and performs any tasks according to the defined scenarios. You can utilize this opportunity to execute periodic tasks, for e.g.:

  • Clear logs
  • back up
  • Scripts execution

Check out the example below.

Create Environment

1. Sign in to your dashboard.

2. Click on Create Environment.

3. In the Environment topology window, you will have options to select the desired application server and database of your choice (for instance, Tomcat and MySQL). Once the selection is done, type the name of the environment and click on the “Create” button to initiate the creation process.

Your environment including both Tomcat and MySQL nodes will be created in minutes.

Upload Script

1. Navigate to the configuration directory of your application server.

2. If you are using the PHP server, & wish to run the script, upload it to the folder where your application is located. If you using the JAVA server in your environment, upload the script to the home folder.


1. Click the Config button for your database (MySQL or MariaDB).

2. For The script you wish to run, upload it to the scripts folder.

Note: The script you wish to perform should be an executable file. If it is not, you can utilize built-in interpreters, like Bash, Perl, Python, SED, AWK, or Expect (depending on the script you are using).

Cron Event Scheduler

1. Within the already opened configurations tab, navigate to the cron folder & open the {nodeName} file to access its content.

2. In this section, you can write all the necessary commands to schedule your tasks. These commands should be composed in such a way that Crontab can understand them. The basic syntax of a crontab schedule consists of six fields separated by spaces.

{minute} {hour} {day} {month} {day-of-week} {command-line-to-execute}

Field Range Values
Minute 0-59
Hour 0-23
Day 1-31
Month 1-12
day-of-week 0-7 (where 0-7 mean Sun, 1 = Mon, 2 = Tue, etc.)
command-line-to-execute The path to the program you want to execute

While specifying these values, you need to adhere to the following standards:

  • The fields should be in exact order, with no empty or missing fields.
  • If required you can utilize the wildcard character – the asterisk(“*”). In a crontab file, it represents every possible value for the corresponding field. For example, using “*” in the “hour” field means that the task is “to run every hour”.
  • The “/” character is utilized to specify additional frequency assignments in the crontab schedule. For example, “* / 3” in the “hour” field signifies “every three hours”.
  • For individual parameters, you can specify multiple values by separating them with commas(“,”). For instance, if in the “hour,” you input “1,6,19”, the job will execute “at 1:00, at 6:00, and 19:00 hours”. Also, you can specify the interval using a hyphen(“-”), for example, “8-17” would mean that the program will run “every hour from 8 to 17 inclusive”.

Pay attention that you specify the full path to your script in the cron command. The path may vary depending on the location of your script & could be one of the following options:

  • For Java compute nodes Folder will be Home:
    • /opt/tomcat/temp/{scriptName} – Tomcat, TomEE
    • /opt/jetty/home/{scriptName} – Jetty
    • /opt/glassfish3/temp/{scriptName} – GlassFish
  • For PHP compute nodes, the folder will be with your application files & scripts:
    • /var/www/webroot/{appFolder}/{scriptName}
  • For MySQL/MariaDB databases folder will be: scripts
    • /var/lib/jelastic/bin/{scriptName}

3. For example, if you wish to execute the script stored in the home folder of Tomcat every minute, then your command should resemble the following command:

*/1 * * * * /opt/tomcat/temp/

Tip: If your script lacks the executable flag and you utilize built-in interpreters, like Bash, Perl, Python, SED, AWK, or Expect (depending on your script), remember to add the following paths after the time settings for explicitly specifying the interpreter:

  • /bin/bash – for Bash
  • /usr/bin/python – for Python
  • /usr/bin/perl – for Perl
  • /bin/sed – for SED
  • /bin/awk – for AWK
  • /usr/bin/expect – for Expect
  • /usr/bin/php – for php-interpreter

In that scenario, your command will be as follows:

*/1 * * * * /bin/bash /opt/tomcat/temp/

4. Please make sure to leave a blank line after the last cronjob entry.

5. To apply the settings, Save the changes.

That concludes the process! As you can see, scheduling your tasks with the platform is a straightforward process. Enjoy the convenience and efficiency that automating brings by allowing you to execute tasks according to your preferred schedule. Optimize your time and resources with the ease of task automation.