Setting Up Cronjob

Setting Up Cronjob

Cron is a time-based scheduler for Unix-like operating systems. It allows commands and shell scripts to run automatically at specified times, dates, or recurring intervals.

The platform supports cron-based automation for recurring tasks such as clearing logs, creating backups, and running application or database scripts.

Logs ClearingRun regular cleanup scripts to remove outdated log files.
BackupsSchedule scripts that create application or database backups.
Script ExecutionRun maintenance, reporting, synchronisation, or administration scripts automatically.

Create an Environment

1Sign in to the dashboard

Log in to the platform dashboard.

2Create the environment

Click Create environment.

3Select the topology

Choose the required application server and database, for example Tomcat and MySQL. Enter the environment name and click Create.

The application-server and database nodes are created and displayed in the dashboard.

Upload the Script

Application Server

  1. Click Config for the application server.
  2. Upload the script to the appropriate location:
    • Java server: upload it to the home folder.
    • PHP server: upload it to the folder containing the application.

Database

  1. Click Config for the MySQL or MariaDB node.
  2. Upload the required script to the scripts folder.
The scheduled script should be executable. When it is not executable, use a built-in interpreter such as Bash, Python, Perl, SED, AWK, Expect, or PHP.

Configure the Cron Scheduler

1Open the cron file

In the configuration panel, open the cron folder and then open the {nodeName} file.

Add the required cron commands to this file. Each entry must follow the standard six-field crontab format.

Crontab Format and Values

{minute} {hour} {day} {month} {day-of-week} {command-line-to-execute}
FieldAllowed ValuesDescription
minute0–59Minute when the job runs.
hour0–23Hour in 24-hour format.
day1–31Day of the month.
month1–12Month of the year.
day-of-week0–7Both 0 and 7 mean Sunday; 1 is Monday, 2 is Tuesday, and so on.
command-line-to-executeFull pathAbsolute path to the command or script.
  • All fields must appear in the exact order, with no missing fields.
  • * represents every possible value for a field.
  • / defines an interval, for example every three hours.
  • Use commas for multiple values, for example 1,6,19.
  • Use a hyphen for a range, for example 8-17.
Example: * in the hour field means every hour. A pattern such as */3 means every three units of that field.

Script Paths

Always specify the full path to the script.

Node TypeScript Path
Tomcat / TomEE/opt/tomcat/temp/{scriptName}
Jetty/opt/jetty/home/{scriptName}
GlassFish/opt/glassfish3/temp/{scriptName}
PHP application server/var/www/webroot/{appFolder}/{scriptName}
MySQL / MariaDB/var/lib/jelastic/bin/{scriptName}

Cron Examples

To run a Tomcat script every minute:

*/1 * * * * /opt/tomcat/temp/test.sh

To run the same script through Bash:

*/1 * * * * /bin/bash /opt/tomcat/temp/test.sh

Built-In Interpreters

InterpreterPath
Bash/bin/bash
Python/usr/bin/python
Perl/usr/bin/perl
SED/bin/sed
AWK/bin/awk
Expect/usr/bin/expect
PHP/usr/bin/php

Save and Apply

  1. Make sure there is a blank line after the final cronjob entry.
  2. Save the cron file.
  3. The platform applies the updated schedule.
A missing blank line after the last cron entry can prevent the final scheduled command from being processed correctly.

What’s next?